2013-05-13 220 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

相關問題