由于我更喜欢使用
Eclipse,我以为我会尝试从Visual Studio转换我的项目.昨天我尝试了一个非常简单的小测试.无论我尝试什么,都用“多目标模式”失败. (这类似于
this unanswered question.)
我有三个文件:
Application.cpp:
using namespace std; #include "Window.h" int main() { Window *win = new Window(); delete &win; return 0; }
在window.h:
#ifndef WINDOW_H_ #define WINDOW_H_ class Window { public: Window(); ~Window(); }; #endif
Window.cpp:
#include <cv.h> #include <highgui.h> #include "Window.h" const char* WINDOW_NAME = "MyApp"; Window::Window() { cvNamedWindow(WINDOW_NAME,CV_WINDOW_AUTOSIZE); cvResizeWindow(WINDOW_NAME,200,200); cvMoveWindow(WINDOW_NAME,0); int key = 0; while (true) { key = cvWaitKey(0); if (key==27 || cvGetWindowHandle(WINDOW_NAME)==0) { break; } } } Window::~Window() { cvDestroyWindow(WINDOW_NAME); }
我已经将以下路径添加到编译器包含路径(-I)中:
"$(OPENCV)/cv/include" "$(OPENCV)/cxcore/include" "$(OPENCV)/otherlibs/highgui"
cv cxcore highgui
和以下库搜索路径(-L):
"$(OPENCV)/lib/"
Eclipse,编译器和链接器都成功地包含了头和库.我正在使用GNU C/C++编译器来自Cygwin的链接器.
编译时,会得到以下make错误:
src / window.d:1:***多个目标模式.停止.
Window.d包含:
src/Window.d src/Window.o: ../src/Window.cpp \ C:/Program\ Files/OpenCV/cv/include/cv.h \ C:/Program\ Files/OpenCV/cxcore/include/cxcore.h \ C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h \ C:/Program\ Files/OpenCV/cxcore/include/cxerror.h \ C:/Program\ Files/OpenCV/cxcore/include/cvver.h \ C:/Program\ Files/OpenCV/cxcore/include/cxcore.hpp \ C:/Program\ Files/OpenCV/cv/include/cvtypes.h \ C:/Program\ Files/OpenCV/cv/include/cv.hpp \ C:/Program\ Files/OpenCV/cv/include/cvcompat.h \ C:/Program\ Files/OpenCV/otherlibs/highgui/highgui.h \ C:/Program\ Files/OpenCV/cxcore/include/cxcore.h ../src/Constants.h \ ../src/Window.h C:/Program\ Files/OpenCV/cv/include/cv.h: C:/Program\ Files/OpenCV/cxcore/include/cxcore.h: C:/Program\ Files/OpenCV/cxcore/include/cxtypes.h: C:/Program\ Files/OpenCV/cxcore/include/cxerror.h: C:/Program\ Files/OpenCV/cxcore/include/cvver.h: C:/Program\ Files/OpenCV/cxcore/include/cxcore.hpp: C:/Program\ Files/OpenCV/cv/include/cvtypes.h: C:/Program\ Files/OpenCV/cv/include/cv.hpp: C:/Program\ Files/OpenCV/cv/include/cvcompat.h: C:/Program\ Files/OpenCV/otherlibs/highgui/highgui.h: C:/Program\ Files/OpenCV/cxcore/include/cxcore.h: ../src/Window.h:
我尝试从Window.d(从第2行开始)删除所有OpenCV标头,但是错误仍然存在.此外,我已经更新了Eclipse和OpenCV,都无济于事.
你有什么想法值得尝试吗?我愿意尝试任何事情!
@H_301_42@