Eclipse CDT 找不到 opencv 2 头文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9658549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Eclipse CDT can't find opencv 2 header files
提问by Geniedesalpages
I installed opencv 2.3.1 with macports and the newest Eclipse CDT. Now I'm trying to compile this code:
我使用 macports 和最新的 Eclipse CDT 安装了 opencv 2.3.1。现在我正在尝试编译此代码:
> #include <iostream.h>
> #include <cv.h> // or opencv.hpp, no difference
>
> int main(int argc, char **argv) {
>
>
> }
I have done all the steps of http://opencv.itseez.com/doc/tutorials/introduction/linux_eclipse/linux_eclipse.htmlbut the output of the compiler is:
我已经完成了http://opencv.itseez.com/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html 的所有步骤,但是编译器的输出是:
> make all Building file: ../main.cpp Invoking: GCC C++ Compiler g++
> -I/opt/local/include/opencv -I/opt/local/include/opencv2 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp" In file included from
> /usr/include/c++/4.2.1/backward/iostream.h:31,
> from ../main.cpp:8: /usr/include/c++/4.2.1/backward/backward_warning.h:32:2: warning:
> #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section
> 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of
> the deprecated header <iostream.h>. To disable this warning use
> -Wno-deprecated. In file included from ../main.cpp:9: /opt/local/include/opencv2/opencv.hpp:46:33: error:
> opencv2/core/core_c.h: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:47:33: error:
> opencv2/core/core.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:48:39: error:
> opencv2/flann/miniflann.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:49:39: error:
> opencv2/imgproc/imgproc_c.h: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:50:39: error:
> opencv2/imgproc/imgproc.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:51:35: error:
> opencv2/video/video.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:52:45: error:
> opencv2/features2d/features2d.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:53:43: error:
> opencv2/objdetect/objdetect.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:54:39: error:
> opencv2/calib3d/calib3d.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:55:29: error: opencv2/ml/ml.hpp:
> No such file or directory /opt/local/include/opencv2/opencv.hpp:56:39:
> error: opencv2/highgui/highgui_c.h: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:57:39: error:
> opencv2/highgui/highgui.hpp: No such file or directory
> /opt/local/include/opencv2/opencv.hpp:58:39: error:
> opencv2/contrib/contrib.hpp: No such file or directory make: ***
> [main.o] Error 1
>
> **** Build Finished ****
What am I doing wrong?
我究竟做错了什么?
回答by Mina Almasry
okay.. I have had a lot of trouble in this myself.
好吧..我自己在这方面遇到了很多麻烦。
You need to look int the opencv folder structure that you installed for these header files yourself. Sometimes they're not in the place the install guide tells you they are.
您需要自己查看为这些头文件安装的 opencv 文件夹结构。有时它们不在安装指南告诉您的位置。
In my computer for example, most of the header files I needed are in:
以我的电脑为例,我需要的大部分头文件都在:
[INSTALL DIRECTORY]/include/opencv [INSTALL DIRECTORY]/include/opencv2
[安装目录]/include/opencv [安装目录]/include/opencv2
but SOME were in:
但有些人在:
[INSTALL DIRECTORY]/modules/core/include/opencv2 [INSTALL DIRECTORY]/modules/highgui/include/opencv2 etc
[安装目录]/modules/core/include/opencv2 [安装目录]/modules/highgui/include/opencv2 etc
you need to find those include files. Then go to your IDE (eclipse). In eclopse there should be a setting for the "include directories"
你需要找到那些包含文件。然后转到您的 IDE (eclipse)。在 eclopse 中应该有一个“包含目录”的设置
Set your IDE to look for include files in the directories where you know the include files are.
将您的 IDE 设置为在您知道包含文件所在的目录中查找包含文件。
Then make sure you add the libraries. Ask if you need help with that.
然后确保添加库。询问您是否需要帮助。
回答by dips
The errors listed above shows that you have not specified the paths of include directories.first you search for the include directories in your installation folder.Generally they are in /home/usr/include/opencv and /home/usr/local/include/opencv
上面列出的错误说明你没有指定include目录的路径。首先你在你的安装文件夹中搜索include目录。一般它们在/home/usr/include/opencv和/home/usr/local/include/ opencv
After locating these files you open project properties in Eclipse CDT. Select GCC C++ compiler -- directories and add the include directories there. Select GCC C++ Linker option and give the library path generally it is /usr/local/lib Specify the libraries in quotes too e.g. "cv" , "highgui" etc.This will complete the configuration. Hope it helps.
找到这些文件后,您可以在 Eclipse CDT 中打开项目属性。选择 GCC C++ 编译器 -- 目录并在那里添加包含目录。选择 GCC C++ Linker 选项并给出库路径,一般是 /usr/local/lib 用引号指定库,例如 "cv" , "highgui" 等。这样就完成了配置。希望能帮助到你。