Here is a tutorial for make file in Linux: http://mrbook.org/tutorials/make/
Here is a make file example:
all: hello
hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello
main.o: main.cpp
g++ -c main.cpp
factorial.o: factorial.cpp
g++ -c factorial.cpp
hello.o: hello.cpp
g++ -c hello.cpp
clean:
rm -rf *o hello
For me this line is confusing main.o: main.cpp
What does it mean? As I understand, it means target main.o
has a main.cpp
dependency. But there is no target with main.cpp
It means a target (main.o
) has a dependency (main.cpp
) which that dependency (main.cpp
) itself is not a target. So what is it (main.cpp
)?