PROGS = frequencies huffman encode
OBJS = frequencies.o huffman.o encode.o
all: $(OBJS)
g++ -o $(PROGS) $(OBJS)
frequencies.o: frequencies.cpp
g++ -c frequencies.cpp
huffman.o: huffman.cpp
g++ -c huffman.cpp
encode.o: encode.cpp
g++ -c encode.cpp
clean:
rm -f $(EXES) $(OBJS)
but that all target doesnt work. How do I make it compile each executable?
And there are tabs on those code lines...the post seemed to have taken them out...
[edited by - chadmv on April 20, 2004 12:49:13 AM]
multiple executables in a makefile
Hi, I'm trying to get my makefile to compile 3 different executables...but I'm having trouble.
Heres what I have
You just can''t compile multiple targets with one invocation of gcc that way. You might be able to hack it using ''xargs'' (this is a unix thing and I don''t know enough about it to really help), but I think what you really need is something more like:
PROGS = frequencies huffman encode
OBJS = frequencies.o huffman.o encode.o
all: $(PROGS)
frequencies: frequencies.o
g++ -o frequencies frequencies.o
frequencies.o: frequencies.cpp
g++ -c frequencies.cpp
huffman: huffman.o
g++ -o huffman huffman.o
huffman.o: huffman.cpp
g++ -c huffman.cpp
encode: encode.o
g++ -o encode encode.o
encode.o: encode.cpp
g++ -c encode.cpp
clean:
rm -f $(PROGS) $(OBJS)
(I can''t type tabs apparently. But you know where they go )
Basically, I made a target for each individual app, and set up "all" recursively to build those targets.
PROGS = frequencies huffman encode
OBJS = frequencies.o huffman.o encode.o
all: $(PROGS)
frequencies: frequencies.o
g++ -o frequencies frequencies.o
frequencies.o: frequencies.cpp
g++ -c frequencies.cpp
huffman: huffman.o
g++ -o huffman huffman.o
huffman.o: huffman.cpp
g++ -c huffman.cpp
encode: encode.o
g++ -o encode encode.o
encode.o: encode.cpp
g++ -c encode.cpp
clean:
rm -f $(PROGS) $(OBJS)
(I can''t type tabs apparently. But you know where they go )
Basically, I made a target for each individual app, and set up "all" recursively to build those targets.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement