Thursday, 15 August 2013

using .o files in makefile

using .o files in makefile

I've just learn something about makefile and here is my first question for
it.I have main.cpp hello.cpp factorial.cpp and functions.h files
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
In the code above, why files have an extention .o ? shouldnt be .cpp or
what is the differences between using .cpp and .o

No comments:

Post a Comment