Include OpenCV for Project in C++

Viewed 520

I feel like this should be basic, but I can't find anything for it online. I downloaded OpenCV and can't figure out how to have my projects recognize it. When I try to include it with like

#include <opencv2/core/version.hpp>

I get the error:

"No such file or directory"

The only solution I've tried is to add /usr/include/opencv4/ to my PATH. Also, I am running ArchLinux if that is helpful to know.

3 Answers

So I ended up just moving the directory /usr/include/opencv4/opencv2 to /usr/include and that worked. Unless there are any ways to add directories to the list of directories that c++ checks when running the #include, this is the only way I've figured to solve it.

Try changing these three:

PATH=$PATH:/usr/bin
CPATH=$CPATH:/usr/include/opencv4
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64:/usr/lib
Related