In make, what is the difference between:
%.o: %.cpp foolib.h
$(CXX) -c $< -o $@ $(CXXFLAGS)
and
.cpp.o: foolib.h
$(CXX) -c $< -o $@ $(CXXFLAGS)
?
Also, am I right in understanding that foolib.h
should be included in the rules as shown above if the changes made in the header are to be (re)compiled even when there is no change in the .cpp files?
.cpp.o:
syntax is Old-Fashioned Suffix Rules.
Am I right in understanding that foolib.h should be included in the rules as shown above if the changes made in the header are to be (re)compiled even when there is no change in the .cpp files?
You are right. However, maintaining header dependencies this way is tedious and error-prone. People normally use auto-generated header dependencies.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments