Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse + CDT + Cygwin: How do you fix the "Multiple targets" bug?

UPDATE 1: My original post was too long and obscured the real problem. I have discovered exactly what is causing the "Multiple targets" bug when Make is called.

UPDATE 2: I found out that this 'Multiple Targets' bug is caused by GNU Make version 3.8.1 (see here1 and here2). GNU Make 3.8.1 is the current GNU Make released with Cygwin. To summarize the link: The old v3.8.0 handled windows paths fine and the newer v3.8.1 reports errors for windows paths (maybe it's a passive aggressive jab from the FSF?).


When you start a new project in Eclipse+CDT+Cygwin w/o external includes/libraries, everything works fine for me.

As soon as I try to use an external include/library I get the "Multiple targets" bug.

Here is exactly the steps needed to reproduce the bug on Windows+Eclipse+CDT+Cygwin:

  1. Project project properties --> C/C++ Build --> Settings --> Tool Settings --> Cygwin C Compiler --> Includes --> Include Paths (-I) -- > Add Button --> Pick directory --> "C:\dir1\dir2"
  2. I hit build.
  3. It builds with no errors the first time.
  4. I hit build again... I get build errors "Multiple targets. Stop.".
  5. I click on the error.

Eclipse pulls up a makefile. The error happens when make sees the windows path for the new include file from the external library:

# NOTE: Error happens when the first "C:/" occurs
src/main.d src/main.o: ../src/main.c C:/dir1/dir2/ExternalLibrary.h

The reason for Make getting an error "Multiple targets" is because it sees the ":" which is part of the Make syntax for declaring a target. When there are two ":", Make errors out because it doesn't know what to do with "Multiple targets."


I can not edit the makefiles manually because they are immediately regenerated and overwritten [UPDATE: by Eclipse-CDT]. Given that I can't manually edit the makefile.

  1. Is there any way for Eclipse to NOT use the "C:\" path? or tell make to ignore the "C:\" path?
  2. Is this an Eclipse+CDT+Cygwin bug?
  3. If you use Eclipse+CDT+Cygwin... please lend a hand (I don't want to use Visual Studios...)! Maybe I am using Eclipse+CDT+cygwin wrong? How do YOU get External Library includes to work?

*Very very frustrated*

Trying to stay Open-Source and cross-platform user,

Trevor

like image 360
Trevor Boyd Smith Avatar asked Oct 25 '22 02:10

Trevor Boyd Smith


1 Answers

Turns out the "multiple targets" issue is caused by the current version of GNU Make installed from Cygwin. GNU Make 3.8.1 is the current GNU Make released with Cygwin.

The GNU Make 3.8.1 does not handle windows paths that contain "C:\". So every time your make file has a windows path with "C:\" you get a build error "multiple targets".

The solution I ended up doing is to download a fixed GNU Make v3.8.1. See Here1 or Here2. Then Eclipse+CDT+Cygwin worked fine again.

Update (05-feb-2015): With an updated cygwin and a new Make (4.0.x) then the problem goes away. https://superuser.com/questions/154418/where-do-i-get-make-for-cygwin

like image 156
Trevor Boyd Smith Avatar answered Oct 30 '22 22:10

Trevor Boyd Smith