Using opencv in linux

Well, the error message says it all. It doesn’t find the OpenCVConfig.cmake file, so you have to set the path manually. Add:

set(OpenCV_DIR "/usr/local/lib/cmake/opencv4")

(or whatever your path is) to the CMakeLists.txt file.

To build your app manually, it’s a bit more complicated, as there are a dozen lib files to link your application to. If you have OpenCV built with pkg-config enabled, it’s easier:

gcc mycode.cpp -o mycode `pkg-config opencv4 --cflags` `pkg-config opencv4 --libs`