#include <opencv2/opencv.hpp> (and others) don't work

asked 2020-03-19 15:21:04 -0500

s8am gravatar image

updated 2020-03-20 05:18:49 -0500

berak gravatar image

I have installed OpenCV on my Linux computer using this tutorial: https://docs.opencv.org/master/d7/d9f... The installation process went without problems, but now I cant use the libraries in my CLion project. I have edited the following lines to my CMakeLists.txt as described in various tutorials:

cmake_minimum_required(VERSION 3.15)


find_package(OpenCV REQUIRED)
add_executable(OCRsrc main.cpp)

target_link_libraries(OCRsrc $(OpenCV_LIBS))

after make the following error appears:

fatal error: opencv2/opencv.hpp: 
No such file or directory   
#include <opencv2/opencv.hpp>

if I change the line to #include<opencv4/opencv2/opencv.hpp> the include works, but the build still fails, as the files included in this header cant be located. Did something go wrong with the folder structure when I installed the library? The headers I would want to include are in /usr/local/include/opencv4/opencv2/

The variable OpenCV_INCLUDE_DIRS gets set to /usr/local/include/opencv4

edit retag flag offensive close merge delete