简体   繁体   中英

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

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?

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)"

I know it's late but posting it here for future references.

If you're using OpenCv for Node.js with the npm package opencv4nodejs which in turn has a dependency on node-gyp , this error is expected when the package installation path contains whtespaces. node-gyp is known to not handle whitespaces well.

So, ideally the path shouldn't be something like this C:\\Program Files\\some_dir .

Try installing the package in a path without any whitespace and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM