J
Jess
Hello,
I am now trying to use makefile to compile C++ programs. My makefile
looks like:
f1.o : f1.cpp h1.h h2.h
g++ -c f1.cpp
f2.o : f2.cpp h2.h h3.h
g++ -c f2.cpp
final.o : final.cpp h4.h h5.h
g++ -c final.cpp
final : f1.o f2.o final.o
g++ f1.o f2.o final.o -o final
In other words, to make a ".o" file, I put its corresponding ".cpp"
and all the "included" ".h" files as dependent files. For the
executable file ("final" above), I put all the ".o" files as dependent
files, without any other ".h" files. Is this the correct approach?
Or, is there a simpler way? Additionally, is there anything important
missing from my makefile?
Thanks a lot!
I am now trying to use makefile to compile C++ programs. My makefile
looks like:
f1.o : f1.cpp h1.h h2.h
g++ -c f1.cpp
f2.o : f2.cpp h2.h h3.h
g++ -c f2.cpp
final.o : final.cpp h4.h h5.h
g++ -c final.cpp
final : f1.o f2.o final.o
g++ f1.o f2.o final.o -o final
In other words, to make a ".o" file, I put its corresponding ".cpp"
and all the "included" ".h" files as dependent files. For the
executable file ("final" above), I put all the ".o" files as dependent
files, without any other ".h" files. Is this the correct approach?
Or, is there a simpler way? Additionally, is there anything important
missing from my makefile?
Thanks a lot!