[英]fatal error: opencv2/core.hpp: No such file or directory compilation terminated in opencv4
In opencv4 while compiling code, I am getting this error:在编译代码时在opencv4中,我收到此错误:
fatal error: opencv2/core.hpp: No such file or directory
compilation terminated.
I properly installed opencv4.我正确安装了 opencv4。 Why am I getting an error?为什么我收到错误?
Try installing the -dev
or -devel
package for OpenCV2 to get the header file.尝试为 OpenCV2 安装-dev
或-devel
包以获取头文件。
sudo apt-get install libopencv-core-dev
on Debian and Ubuntu, and sudo yum install opencv-devel
on Fedora.在 Debian 和 Ubuntu 上使用sudo apt-get install libopencv-core-dev
,在 Fedora 上使用sudo yum install opencv-devel
。
Once that's done, append $(pkg-config --cflags opencv)
to your compiler command:完成后,将$(pkg-config --cflags opencv)
附加到您的编译器命令:
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.如果您使用 OpenCv for Node.js 和 npm 包opencv4nodejs
而依赖于node-gyp
opencv4nodejs
,则当包安装路径包含 whtespaces 时会出现此错误。 node-gyp
is known to not handle whitespaces well.众所周知, node-gyp
不能很好地处理空格。
So, ideally the path shouldn't be something like this C:\\Program Files\\some_dir
.所以,理想情况下,路径不应该是这样的C:\\Program Files\\some_dir
。
Try installing the package in a path without any whitespace and it should work.尝试在没有任何空格的路径中安装包,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.