10

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!

Community
  • 1
  • 1
Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187
  • You should probably have included the makefile. As this is an error from `make`, that's probably more important than the actual C++ source code. – skyking Dec 21 '15 at 07:25

9 Answers9

26

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.

James McNellis
  • 348,265
  • 75
  • 913
  • 977
  • Yes, I'm running GCC from a Cygwin installation. Your answer is definitely pointing in the right direction. Coincidentally, I was just busy replacing `C:\` with `C\:/`, but then the compiler simply can't find the headers anymore. The same holds for replacing it with `/cygdrive/c/`. I'm fairly certain this will resolve the `make` problem, but how do I get them to work together? – Paul Lammertsma Mar 08 '10 at 15:04
  • I don't know how to prevent that Markdown from being escaped. Nevertheless, I had replaced "C:\" with "C\:/". – Paul Lammertsma Mar 08 '10 at 15:11
  • 1
    Just as a test, I copied all includes and libraries into my project path. Sure enough, it builds and runs. The problem seems to be specifying an absolute path. – Paul Lammertsma Mar 08 '10 at 15:25
  • 3
    When I had this problem before, we resolved it by simply replacing all of the `c:/` with `/cygdrive/c` (including in the environment variables it pulled in), and that solved our problem. I don't think you can use the `c:/` format path with GNU make (though there may be some Windows-specific build of it; I don't work with Cygwin enough to know). The network mount might still work--map `c:` as `c`, then you can access it from `\\mycomputer\c`. Other than that, I'm out of ideas :(. – James McNellis Mar 08 '10 at 15:30
  • One other idea: are you running `make` from a Cygwin shell? If not, the `/cygdrive` mappings won't be available. – James McNellis Mar 08 '10 at 15:32
  • maybe its possible to create enviroment variablse which point to your include directories, and use thos enviroment variables instead of the absolute path.. – smerlin Mar 08 '10 at 15:59
  • No; `make` is invoked by Eclipse. – Paul Lammertsma Mar 08 '10 at 15:59
  • 1
    Try running Eclipse from the Cygwin shell. – James McNellis Mar 08 '10 at 16:03
  • Yes, it appears that that works. However, Eclipse runs so poorly that I think I will just use relative paths for the time being. – Paul Lammertsma Mar 08 '10 at 16:27
6

according to other internet sources this is related to a problem that cygwin make has with windows path names, specially the c:. For me it workes fine with setting relative paths instead.

e.g. if you have something like

proj/mymodule/headers/afile.h
proj/mymodule/source/abc/afile.c

just add ../mymodule/headers/ as include path in the project configuration for the compiler this will find the header afile.h and will generate make files with relative path. (compiler command will have the statement -I../mymodule/headers/ )

looks like execution directory is always the project base directory.

Lesmana
  • 25,663
  • 9
  • 82
  • 87
marco
  • 61
  • 1
  • 1
4

On Cygwin, GNU make version 3.81-1 delivered by the default setup program doesn't work with the automatic header file dependencies, generated by the compilers. The error message you will see because of this bug will look something like this:

Here are two suggested fixes: - Try to obtain the previous version (3.80) - Obtain a fixed 3.81 version, for example from http://www.cmake.org/files/cygwin/make.exe

src: https://projects.coin-or.org/BuildTools/wiki/current-issues

Simply replace the make file in your "C:\cygwin\bin\" folder (or wherever cygwin is installed) with the "fixed" make file mentioned above.

Community
  • 1
  • 1
barcaleiku
  • 39
  • 1
1

Looks like there is a simple way to solve this. Just change the "Current Builder" from "GNU Make Builder" to "CDT Internal Builder" in Project properties->C/C++ Builder->Tool Chain Editor->Current Builder will do.

To me, this problem is caused by the automatically generated "XXX.d" dependency files in Debug directory (or release :), which were generated by gcc -MF as a side-effect to gcc -c. But GNU make obviously forgot to add quotations around file names when -MF.

"CDT Internal Builder" does not use makefile nor GNU make at all. Eclipse manage the build process itself.

If you insist to use GNU make, this doesn't work

Crow Soup
  • 5
  • 2
1

I also had the problem of multiple target patterns reported by make when using eclipse on windows/cygwin. I solved the problem as suggested above by using only relative paths. I didn't realize that I had absolute paths, but when I specified an include directory using the project directory, eclipse expanded it into the full path.

For instance, if you add a path relative to the workspace, eclipse generates ""${workspace_loc:/include}"" which will expand to something starting with "c:\". This is why it was happening in my case.

I simply replaced the complex string above with "../../include" and it solved my problem.

Thagomizer
  • 111
  • 1
  • 5
0

You can also delete *.d files under output folders and then build

Debug/src/
duckduckgo
  • 1,280
  • 1
  • 18
  • 32
0

I'm working in the Cygwin environment, on Windows 7 (64bit), using Eclipse Kepler CDT for C++.

In Eclipse, goto

Project --> Properties --> C++ Builder --> Settings --> Tool Settings Tab

Cygwin C++ Compiler --> Includes

In the Include paths (-I) add 2 paths: "C:\cygwin64\usr\include\libxml2"

and "/cygdrive/c\cygwin64\usr\include\libxml2"

tzg
  • 616
  • 1
  • 8
  • 17
0

One change that worked for me (I use Cygwin and SSH terminal into an SVN server in parallel) was to delete the .d files. When I called the make -f makefile from Cygwin, it broke something. I usually compile from the Putty terminal, and after deleting the .d files from my project it stopped complaining about the multiple targets.

Natalie Hedström
  • 2,607
  • 3
  • 25
  • 36
Brick
  • 1
  • 1
0

The error "multiple target patterns. Stop." will occur because src/Window.d have the paths generated by compiler in windows platform as:

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 \

If you import this project into Eclipse in Linux platform, I would recommend you to give a clean build so that next build generates the path in Linux format as:

/home/user/OpenCV/cv/include/cv.h \ /home/user/OpenCV/cxcore/include/cxcore.h \ /home/user/OpenCV/cxcore/include/cxtypes.h \ /home/user/OpenCV/cxcore/include/cxerror.h \

The same is applicable, if you are using cygwin. The path format in cygwin is linux like format /cygdrive/c/ instead of C:/