Mail Archives: djgpp/1998/02/02/00:29:55
At 01:48 2/1/1998 -0800, Rik Blok wrote:
>I'm trying to figure out how to use a makefile to create executables
>from both C and C++ sources. My problem is that the default rule for
>the linker assumes that the file is just a C file and doesn't link in
>the C++ libraries.
So you have to use explicit rules.
>
>makefile
>--------
># executables
>ccprog: ccprog.o common.o
Try this:
ccprog: ccprog.o common.o
gxx $(LDFLAGS) -o $@ $^
I think you get the idea.
>justc: justc.o common.o
>
># object files
>ccprog.o: ccprog.cc ccprog.h common.h
>justc.o: justc.c justc.h common.h
>common.o: common.c common.h
>
># end of makefile
>
>How do I make the linker link in -lgpp -lstdxxx etc. just for the ccprog
>and not for justc?
>
>I think it works ok if I use something like
> ccprog: ccprog.cc ccprog.h common.c common.h
>but that seems to me to be rather bad style and loses the advantage of
>conditional recompilation.
Yes it is. The solution I suggested is the one usually used.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -