Mail Archives: djgpp/2000/04/07/13:57:17
On Wed, 5 Apr 2000, Jonathan Meunier wrote:
> Make knows how to compile C files, but is there any easy way to make it
> compile C++ files?
Make knows how to compile C++ files as well, it recognizes .cc, .cpp,
and .C (Capital C) extensions. Please try it.
> What I'm doing right now is this:
>
> CC = gpp
> CFLAGS = -Wall -O3
>
> OBJS = file1.o file2.o
> HEADS = file1.h file2.h
>
> file.exe: $(OBJS)
> $(CC) $(CFLAGS) -o $@ $(OBJS)
> file1.o: $(HEADS)
> $(CC) $(CFLAGS) -c file1.cpp
> file2.o: $(HEADS)
> $(CC) $(CFLAGS) -c file2.cpp
>
> This gets very long in big projects.. :\
This is redundant, Make already knows all this stuff. If you have
specific problems, please report them.
> There must be a way to simply
> tell make to take each .cpp file and compile them with gpp with those
> flags.
You don't need gpp to compile, only to link. And in a Makefile, this
isn't really a problem: you can simply add -lstdcxx to the LDLIBS
variable, like this:
LDLIBS = -lstdcxx
Alternatively, say this:
LINK.cc = gpp $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
LINK.cpp = gpp $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS)
- Raw text -