Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fatal error: opencv2/core.hpp: No such file or directory compilation terminated in opencv4

Tags:

c++

linux

opencv

In opencv4 while compiling code, I am getting this error:

fatal error: opencv2/core.hpp: No such file or directory
compilation terminated.

I properly installed opencv4. Why am I getting an error?

like image 299
user Avatar asked Nov 15 '25 20:11

user


1 Answers

Try installing the -dev or -devel package for OpenCV2 to get the header file.

sudo apt-get install libopencv-core-dev on Debian and Ubuntu, and sudo yum install opencv-devel on Fedora.

Once that's done, append $(pkg-config --cflags opencv) to your compiler command:

export CC="gcc $(pkg-config --cflags opencv)"
like image 117
S.S. Anne Avatar answered Nov 17 '25 10:11

S.S. Anne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!