c++ - Makefile - Efficient Compiling -


let's say, compiling hello.c requires car.c , water.c. main.c requires hello.c.

when requires, mean compiled output differ if things requires modified in way.

so, if car.c or water.c changed, hello.c need recompiling.

then, correct makefile?

main: main hello.o    gcc main.c hello.c -o main  hello.o: water.c, car.c    gcc water.c car.c -o hello.o 

otherwise, if it's not correct, can explain me why wrong , give me example?

thank you!

let's say, compiling hello.c requires car.c , water.c. main.c requires hello.c.

this statement doesn't make lot of sense. thing mean either these aren't c or c++ source files, rather other language uses these names confusingly, or contain #include directives include other files.

in latter case (which rare, , poor design), there's no need specify included files on command line, since gcc include them you. need specify dependencies in makefile:

main: main.c hello.c car.c water.c         gcc -o main main.c 

since main.c has #include "hello.c" , hello.c has #include "car.c" , #include "water.c", 1 compile gets everything.

if these other language, , mean different, gcc can't understand (or compile) them @ all...


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -