Hi there.
I know there are many supposed duplicates for this matter, but since none of the answers worked for me I'd rather ask another question.
My project won't compile with CMake:
Found package configuration file: /usr/share/OpenCV/OpenCVConfig.cmake but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
My CMakeLists.txt is as follows:
cmake_minimum_required( VERSION 2.8 )
project( Tests )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
if(WIN32)
# set( CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH} C:\\OpenCV" )
set( OpenCV_DIR "C:\\OpenCV\\build" )
elseif(UNIX)
set( OpenCV_DIR "/usr/share/OpenCV" )
set( PKG_CONFIG_PATH "/usr/lib/pkgconfig" )
endif()
find_package( OpenCV REQUIRED )
if( OpenCV_FOUND )
message( "Found OpenCV" )
message( "Includes: " ${OpenCV_INCLUDE_DIRS} )
else()
message( "OpenCV not found, woot" )
endif( OpenCV_FOUND )
add_executable( Test ShapeRecognition/prog.cpp )
target_link_libraries( Test ${OpenCV_LIBS} )
The error happens on the line find_package(OpenCV REQUIRED), thus none of the messages below are displayed anyway.
BUT while compiling in console, with the command:
g++ -o prog -std=c++11 `pkg-config --libs --cflags opencv` prog.cpp
The compilation happens without a problem, and the program can be launched perfectly fine.
The command "pkg-config --libs opencv" gives me (a bit long, I agree):
-lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn -lopencv_dpm -lopencv_fuzzy -lopencv_line_descriptor -lopencv_optflow -lopencv_plot -lopencv_reg -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_rgbd -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_face -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_flann -lopencv_xobjdetect -lopencv_objdetect -lopencv_ml -lopencv_xphoto -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_photo -lopencv_imgproc -lopencv_core
The command "pkg-config --cflags opencv" simply gives me (OpenCV_PREFIX is set to /usr):
-I/usr/include/opencv
If anyone has a solution, I'd gladly take it.