make clean will always work, but then your make file could be replaced with a simple shell script. The point of make is that it only rebuilds the parts that need to be rebuilt.
The format for a make is:
rule: dependency
-TAB-command...
That is to say. If I have class with header file a.cpp a.h
and a driver.cpp with the main and it's functions; then the make file would look like this (replacing the leading 3 spaces of the second line of each rule with a real tab char):
Code:
all: driver.o a.o a.h
g++ driver.o a.o -o prog
driver.o: driver.cpp
g++ -c driver.cpp
a.o: a.cpp a.h
g++ -c a.cpp
So, to do all, it checks to see if the rule
driver.o, the rule
a.o and the file
a.h are up to date. The header is needed to link, so it's needs to be listed as a dependency everywhere it's included. If the dependancies of any of the dependencies are found to be out of date, it executes the rules for that dependency and then reruns the command for
all.
If the file isn't listed as dependency for the rule that makes that part of the program, then changing that file won't cause anything to happen -- which is your problem. Your rules are right, but you need to rm the
.os (make clean typically does something like "rm -f *.o *~ core"). The
.os seem to be set properly as dependencies but not the .cpp or .h that you were editing.
Please list your .cpp .o, specify which has main() in it and show us your makefile or Makefile... Then we can tell you what is causing this inconvience.
See Greg's tutorial on make for more information:
[plug=shameless]
[/plug]