2013-05-13 33 views
1

您好我在Eclipse中遇到麻烦,包括OpenCV库。我遵循很多教程,但我不能编译任何东西。这是控制台的输出。Eclipse + OpenCV + Cygwin - > cv.h:没有这样的文件或目录

Building file: ../hand.c 
Invoking: Cygwin C Compiler 
gcc -O2 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"hand.d" -MT"hand.d" -o"hand.o" "../hand.c" 
cygwin warning: 
    MS-DOS style path detected: D:\Eclipse_workspace_C++\HelloWorld\Default 
    Preferred POSIX equivalent is: /cygdrive/d/Eclipse_workspace_C++/HelloWorld/Default 
    CYGWIN environment variable option "nodosfilewarning" turns off this warning. 
    Consult the user's guide for more details about POSIX paths: 
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames 
../hand.c:3:16: fatal error: cv.h: No such file or directory 
compilation terminated. 
subdir.mk:18: recipe for target `hand.o' failed 
make: *** [hand.o] Error 1 

我正在使用OpenCV2.0。

我在proyect属性中配置了C/C++构建 - >设置 - >工具设置选项卡 - >编译器和链接器来添加opencv库和标题,但我无法编译它。

我的eclipse项目的ScreenShoot。

enter image description here

+1

做以下检查1)你有包括 “../include/opecv” 和” ../include/opencv2" 路径? 2)检查opencv和cygwin的环境变量是否设置正确。 – 2vision2 2013-05-13 07:00:19

+0

嗨,环境变量设置。关于包含opencv2?我在opencv 2.0目录中没有这个文件夹。 – Patrick 2013-05-13 07:02:51

+0

你不能使用opencv4 +版本吗?为什么坚持2.0? – 2vision2 2013-05-13 08:10:15

回答

2

解决了!

在Windows

1的步骤配置Eclipse和OpenCV 2.4.5)安装后opencv的环境路径包括在安装了OpenCV的目录,我的是OpenCV的\ opencv2.4.5 \建立\包括

2)我使用Cygwin编译c文件。因此,使用CDT for Cygwin配置您的eclipse,并在项目设置中放入下一个配置。

Settings Compiler

Settings Linker

如果你正在使用的MinGW放在那里的链接器设置。对我而言,这只是vc9。

3)我的源文件是这样

#include <stdio.h> 
    #include <stdlib.h> 

    #include <cv.h> 

    int main(void) { 
     puts("Hello World!!!"); 
     return EXIT_SUCCESS; 
    } 
+0

gr8 !!!!!!!!!!!!!!!!!!!!! – 2vision2 2013-05-13 09:12:06

+0

可以编译任何的OpenCV的源文件,如文件:#include 的#include 的#include 的#include using namespace std; int main() { \t IplImage * img1 = cvLoadImage(“lenna.png”); \t cvShowImage(“MyWindow1”,img1); \t cv :: Mat img2; \t cv :: imread(“lenna。PNG”,CV_LOAD_IMAGE_COLOR); \t CV :: namedWindow( “MyWindow2”,CV_WINDOW_AUTOSIZE); \t CV :: imshow( “MyWindow2”,IMG2); \t cvWaitKey(0); \t返回0; } – 2013-06-30 15:46:50

+0

我尝试了几次你的方法,但它不起作用。 – 2013-06-30 16:35:05

相关问题