c – 非常简单的应用程序以Eclipse的“多目标模式”失败

前端之家收集整理的这篇文章主要介绍了c – 非常简单的应用程序以Eclipse的“多目标模式”失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
由于我更喜欢​​使用 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"

我已经将以下库添加链接器(-l)中:

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@

解决方法

你从Cygwin安装工作吗?

在使用Cygwin之前,我已经看到了这个问题 – 基本上,看到:在路径中,认为它是另一个目标定义,因此是错误.

如果您从Cygwin安装工作,您可以尝试将c:/ / / cygdrive / c /替换.如果没有,您可以尝试使用相对路径或使用网络安装,并查看是否修复它.

@H_301_42@ @H_301_42@ 原文链接:https://www.f2er.com/c/115433.html

猜你在找的C&C++相关文章