I am trying to build the OpenCV samples which come with the source package and I get the following:
CMake Error at CMakeLists.txt:10 (ocv_check_dependencies)
I got similar errors. My approach is as following: 1) cd xxx/samples 2) mkdir build 3) cd build 4) cmake .. 5) make Now it works. We could not build individual project under their source files.
error message context:
CMake Error at CMakeLists.txt:10 (ocv_check_dependencies):
Unknown CMake command "ocv_check_dependencies".
This error message happens because cmake can't find the definition of ocv_check_dependencies
That's why the console said Unknown CMake command
If cmake cannot find where ocv_check_dependencies
is defined
Just like @Nick Hockings Said:
ocv_check_dependencies
is a macro defined in Your/OpenCV/path/OpenCVModule.cmake
macro(ocv_check_dependencies)
set(OCV_DEPENDENCIES_FOUND TRUE)
foreach(d ${ARGN})
if(d MATCHES "^opencv_[^ ]+$" AND NOT HAVE_${d})
set(OCV_DEPENDENCIES_FOUND FALSE)
break()
endif()
endforeach()
endmacro()
The fastest way is to copy this snippet above to your CMakeList.txt
file right above where ocv_check_dependencies
is
Therefore, cmake can finally understand what it is
That should do the trick, i hope no one else will bother with this question in the future
Following steps works for me.
Export toolchain path.
cd opencv-3.3.0/samples
cross_cmake && cross_make
cd opencv-3.3.0/samples/cpp/
How to compile OpenCV sample code ?
# For OpenCV 3
cd /path/to/opencv/samples/cpp/
#Compile
g++ -ggdb `pkg-config --cflags --libs opencv` facedetect.cpp -o facedetect
#run
./facedetect
Works for me.
googled from this link
I got it.
In order to build the samples one has to change the default configuration for cmake by providing it via -D
. What I did wrong was that I tried to execute cmake from within the samples
directory.
The proper way to build the samples is invoking cmake like so (from within the root directory of the unpacked archive):
cmake -DBUILD_SAMPLES .
which will turn samples ON. One can proceed using make, make install than. The samples can be found in bin
after building.
See also FAQ
mydragonisland's build instructions almost worked for me; with a minor reordering and including accents:
g++ facedetect.cpp -o facedetect `pkg-config --libs opencv`