Skip to content
Advertisement

OpenCV 3.1.0 won’t compile with CMake

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:

JavaScript

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:

JavaScript

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 (CMAKE_INSTALL_PREFIX is set to /usr):

-I/usr/include/opencv

If anyone has a solution, I’d gladly take it.

Advertisement

Answer

Ok so I figured it out. Too bad I’ve been stuck on this for that long.

I am using CLion, so solution may differ, but all you have to do is to delete the cache and reload the project (I personally went to Tools > CMake > Delete cache and Reload project).

If command line works and CMake doesn’t, I guess this is all you have to do.

I hope it will eventually come to help someone else who’d have such a stupid error.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement