Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
542 views
in Technique[技术] by (71.8m points)

c++ - Very simple application fails with "multiple target patterns" from Eclipse

Since I'm more comfortable using Eclipse, I thought I'd try converting my project from Visual Studio. Yesterday I tried a very simple little test. No matter what I try, make fails with "multiple target patterns". (This is similar to this unanswered question.)

I have three files:

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, 0);
    int key = 0;
    while (true) {
        key = cvWaitKey(0);
        if (key==27 || cvGetWindowHandle(WINDOW_NAME)==0) {
            break;
        }
    }
}
Window::~Window() {
    cvDestroyWindow(WINDOW_NAME);
}

I have added the following paths to the compiler include path (-I):

"$(OPENCV)/cv/include"
"$(OPENCV)/cxcore/include"
"$(OPENCV)/otherlibs/highgui"

I have added the following libraries to the linker (-l):

cv
cxcore
highgui

And the following library search path (-L):

"$(OPENCV)/lib/"

Eclipse, the compiler and the linker all succeed in including the headers and libraries. I am using the GNU C/C++ compiler & linker from Cygwin.

When compiling, I get the following make error:

src/Window.d:1: *** multiple target patterns. Stop.

Window.d contains:

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:

I tried removing all OpenCV headers from Window.d (from line 2 onwards), but the error remains. Also, I've updated Eclipse and OpenCV, all to no avail.

Do you have any ideas worth trying? I'm willing to try anything!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Are you working from a Cygwin installation?

I've seen this problem before using Cygwin--basically, make sees the : in the path and thinks it is another target definition, hence the error.

If you are working from a Cygwin installation, you might try replacing the c:/ with /cygdrive/c/. If not, you might try using relative paths or using a network mount and see if that fixes it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...