suppose i have mainprog.cpp that uses program.h.
how do i create a makefile and how do i run it?
Printable View
suppose i have mainprog.cpp that uses program.h.
how do i create a makefile and how do i run it?
Something like
Note the indent before each $CXX is a real tab character, not spaces. This will catch you out.Code:mainprog.o : mainprog.cpp program.h
$(CXX) -c mainprog.cpp
prog : mainprog.o
$(CXX) -o prog mainprog.o
You save this file as Makefile, and you run it by typing make at the command line prompt.