I installed opencv following the steps on https://docs.opencv.org/trunk/d7/d9f/tutorial_linux_install.html
Except on Step 2, use: cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=YES -D CMAKE_INSTALL_PREFIX=/path/to/opencv/ ..
Then locate the opencv4.pc file, mine was in opencv/build/unix-install/
Now run: $ export PKG_CONFIG_PATH=/path/to/the/file