1

I'm trying to compile a c file where I included a driver for Mongo database. I can compile it successfully from Cygwin but when I turn to Netbeans I get this. I should mention that this happened only after adding "-std=c99" in Additional options for C compiler.

UPDATE:
Successfully compiled it from Netbeans. But the "-std=c99" is driving me mad. If I have it it says (after every compilation if I don't delete the obj files):

build/Debug/Cygwin_4.x-Windows/main.o.d:1: *** multiple target patterns.  Stop.  

UPDATE:
The content of main.o.d is:

build/Debug/Cygwin_4.x-Windows/main.o: main.c \
 c:/mongodb-driver/src/mongo.h c:/mongodb-driver/src/bson.h \
 c:/mongodb-driver/src/platform.h

c:/mongodb-driver/src/mongo.h:

c:/mongodb-driver/src/bson.h:

c:/mongodb-driver/src/platform.h:
Andrew
  • 6,254
  • 16
  • 59
  • 93
  • 1
    So what is in line 1 of `main.o.d`? - Related: [“multiple target patterns” Makefile error](http://stackoverflow.com/q/2100448/269126) – Lumi May 16 '12 at 10:02
  • @Lumi build/Debug/Cygwin_4.x-Windows/main.o: main.c \ – Andrew May 16 '12 at 10:11
  • 1
    And on the next line? A trailing backslash in a Makefile indicates line continuation. Please update your post to include all relevant details, that's better than serving it piecewise in the comment lines. – Lumi May 16 '12 at 10:40
  • @Lumi added the entire content of the main.o.d file – Andrew May 16 '12 at 11:01
  • 1
    There you go, the colons are your problem. The answer given by @fayyazkl is correct, go upvote and accept it. – Lumi May 16 '12 at 11:08
  • @Lumi how can I mount it to not have to edit it everytime? – Andrew May 16 '12 at 11:26

2 Answers2

3

Quoting from an existing answer since you might have the same issue

"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".

application fails with multiple targets from eclipse

Community
  • 1
  • 1
fkl
  • 5,412
  • 4
  • 28
  • 68
2

From your comment:

@Lumi how can I mount it to not have to edit it everytime?

Fix the script that generates main.o.d (and probably lots of other .d files) to write relative paths, or absolute paths that Cygwin's make understands.

Alternatively, consider whether using MinGW instead of Cygwin is an option for you. (But I have the feeling that you'll run into more issues when following that road.)

Ultimately, to cope with Makefiles, you need to read up on how Make works. GNU Make has a comprehensive manual. I found these tips very useful. The best for you, at this stage, would probably be Scott Duckworth's Make tutorial.

Lumi
  • 14,775
  • 8
  • 59
  • 92
  • thanks, MinGW is not an option. I have it installed but it doesn't come with the UNIX libraries I need. – Andrew May 16 '12 at 11:46