Issue
I'm running a C++ program using OpenCV. I've installed all necessary libraries but it seems cmake cannot find OpenCV libraries.
The command port content opencv3
shows my opencv libraries are under these folders:
/opt/local/libexec/
/opt/local/bin/
/opt/local/lib/
/opt/local/include/
but adding set(OpenCV_DIR /opt/local)
before find_package(OpenCV REQUIRED)
didn't work and the same error just pop up every time.
What should I do?
Solution
CMake commands do not separate their arguments via ,
. Thus when you wrote:
set(OpenCV_DIR, /opt/local/share/OpenCV)
You in fact set a variable named OpenCV_DIR,
to /opt/local/share/OpenCV
. You can "fix" it by removing the comma:
set(OpenCV_DIR /opt/local/share/OpenCV)
I say "fix" because this is not a good way of doing things. Your CMakeLists.txt should be free of absolute paths. Instead, set -DCMAKE_PREFIX_PATH=/opt/local
on the command line or in a preset.
Answered By - Alex Reinking