当使用cygwin g ++构建项目时,即使我用-I指示了路径,也找不到包含头文件

时间:2013-05-09 13:49:00

标签: compiler-errors g++ cygwin

我知道有这样一个问题打扰你。但这对我来说很奇怪。请耐心等待我完成我的问题陈述。

背景:Windows vista,cygwin最新版本,opencv 2.4.3

我的项目生成这样的文件,因为opencv安装在d:\ Application \ OpenCV2.4.3 \ opencv:

OPENCV=/cygdrive/d/Application/OpenCV2.4.3/opencv/build
CUSTOM_INCLUDES+=-I${OPENCV}/include -I${OPENCV}/include/opencv -I${OPENCV}/include/opencv2/ml -I${OPENCV}/include/opencv2/highgui -I${SRC_DIR}
CUSTOM_LIBRARIES+= -L${OPENCV}/x86/mingw/lib -lopencv_core -lopencv_highgui -lopencv_imgproc -lopencv_objdetect 

需要构建的头文件是这样的:

#include <iostream>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/core/core_c.h>
blablabla...

执行时:

g++ -c src/ObjectDetector.cpp -Wall  -O3 -ffast-math -funroll-loops   -I/cygdrive/d/Application/OpenCV2.4.3/opencv/build/include -I/cygdrive/d/Application/OpenCV2.4.3/opencv/build/include/opencv -I/cygdrive/d/Application/OpenCV2.4.3/opencv/build/include/opencv2/ml -I/cygdrive/d/Application/OpenCV2.4.3/opencv/build/include/opencv2/highgui -Isrc/ -o build/ObjectDetector.o

哎呀,事实证明:

    In file included from src/ObjectDetector.cpp:10:0:
src/ObjectDetector.h:15:33: fatal error: opencv2/core/core.hpp: No such file or directory

我百分之百肯定opencv2 / core / core.hpp在/cygdrive/d/Application/OpenCV2.4.3/opencv/build/include 中,并使用“”替代&lt; &GT; 。这些都不起作用,我很痛苦。我引用了每个谷歌搜索项目。请帮助我。

谢谢。

1 个答案:

答案 0 :(得分:1)

看起来你正试图将MinGW编译的OpenCV与Cygwin混合;这是行不通的。如果您想在Cygwin上使用OpenCV,请尝试从Cygwin Ports安装libopencv-devel包。