Makefile : why pu .o instead of .c in dependencies? -


in tutorial : http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/

i don't understand why uses .c dependencies in makefile1 , .o in makefile2. can put .o , .c regardless in gcc ? what's advantage of using .o ?

1) it's right there in tutorial: "by putting object files--hellomake.o , hellofunc.o--in dependency list , in rule, make knows must first compile .c versions individually, , build executable hellomake." not strictly correct, can see author meant.

2) can either way, should aware of these 2 methods do. also, compare:

gcc -o hellomake hellomake.c hellofunc.c -i.  gcc -o hellomake hellomake.o hellofunc.o 

the -i. isn't needed in second usage; compiler can't use , ignore it. (yes, know command in tutorial uses it-- author wrong.)

3) biggest advantage know of ability keep object files (foo.o) avoid unnecessary recompilation later; there may others.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -