找不到openCV头文件 [英] can't find openCV head file

查看:184
本文介绍了找不到openCV头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我正在学习openCV.我遵循了openCV网站上的教程. http://docs.opencv.org/doc/tutorials/core /how_to_scan_images/how_to_scan_images.html#howtoscanimagesopencv

Recently I'm learning openCV. I followed the tutorial on openCV website. http://docs.opencv.org/doc/tutorials/core/how_to_scan_images/how_to_scan_images.html#howtoscanimagesopencv

但是,当我使用以下命令编译代码时

However, when I compile my code using following command

g++ loadImage.cpp -o loadImage

命令行显示:

fatal error: 'opencv2/core/core.hpp' file not found
#include <opencv2/core/core.hpp>
     ^

我用brew安装了openCV,我认为还可以.然后我使用emacs进行编辑并直接用g ++编译我的代码,这是问题吗?我搜索了一些类似的问题,但它们是指xCode环境.感谢您的帮助!

I installed openCV with brew, I think it is OK. Then I use emacs to edit and g++ compile my code directly, is that the problem? I searched some similar problems but they refer to xCode environment. Thanks for your help!

推荐答案

您需要告诉g ++它可以在哪里找到头文件.我建议您设置eclipse或任何其他可以为您处理这些东西的IDE(例如Qt Creator或许多其他工具).如果需要,您可以按照OpenCV的设置指南进行操作.

You need to tell g++ where it can find the header files. I recommend you setup either eclipse or any other IDE that can handle that stuff for you (like Qt Creator or many others). You can follow the setup guides for OpenCV for instructions, if needed.

[edit:请注意,我知道也可以设置emacs来处理诸如include和库路径之类的事情,但是我不知道该如何做,因此我建议使用全面的IDE]

[edit: note that I know that emacs can also be setup to handle things like include and library paths, but I have no idea how, hence my recommendation for a full scale IDE]

您还可以在命令行上使用-I指定包含的路径,这也应该起作用.示例:

You can also specify the path to the includes on the command line with -I, then it should also work. Example:

g++ -I/path/to/OpenCV-2.4.9/build/include loadImage.cpp -o loadImage

您可以设置环境变量,因此不必为每个调用都指定它(请参见此页面以获取完整列表,尤其是CPATH及其变体.

There are environment variables you can set so you don't have to specify this for every call (see this page for a complete list, specifically CPATH and it's variants might be of interest.

这篇关于找不到openCV头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆