我使用macports和最新的Eclipse CDT安装了opencv 2.3.1。现在我正在尝试编译这段代码:
> #include <iostream.h>
> #include <cv.h> // or opencv.hpp, no difference
>
> int main(int argc, char **argv) {
>
>
> }
我完成了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 ****
我做错了什么?
答案 0 :(得分:2)
您需要查看为自己为这些头文件安装的opencv文件夹结构。有时他们不在安装指南告诉你的地方。
例如,在我的计算机中,我需要的大多数头文件都在:
[INSTALL DIRECTORY] / include / opencv [INSTALL DIRECTORY] / include / opencv2
但有些人在:
[INSTALL DIRECTORY] / modules / core / include / opencv2 [INSTALL DIRECTORY] / modules / highgui / include / opencv2等
你需要找到那些包含文件。然后转到IDE(eclipse)。在eclopse中,应该有一个“包含目录”的设置
将IDE设置为在您知道包含文件的目录中查找包含文件。
然后确保添加库。询问您是否需要帮助。
答案 1 :(得分:1)
上面列出的错误表明您没有指定包含目录的路径。首先在安装文件夹中搜索包含目录。一般它们位于/ home / usr / include / opencv和/ home / usr / local /包含/ OpenCV的
找到这些文件后,您可以在Eclipse CDT中打开项目属性。选择GCC C ++编译器 - 目录并在那里添加include目录。选择GCC C ++链接器选项并通常给它库路径是/ usr / local / lib 也可以在引号中指定库,例如“cv”,“highgui”等。这将完成配置。 希望它有所帮助。