Structure of a Makefile
- Line 1: dependencies. Name of the file produced by a
compilation, followed by the names of the files on which the
compilation depends. Example:
testJarType.o: JarType.h testJarType.cpp JarType.o
The object file testJarType.o is produced from the header
file JarType.h, the source file testJarTpe.cpp and
the previously compiled object file for the class definition,
JarType.o. The compilation of this last file has to be
specified in a separate group (of two such lines) in the
Makefile.
- Line 2: compiler command.
g++ testJarType.cpp JarType.o -o testJarType
Compiles the source file testJarType.cpp, puts it together
with the previously compiled file JarType.o and produces
and executable file named testJarType.
Careful: the second line has to start with a TAB, not
many spaces. This is important, and very very hard to debug, if
not done properly from the very beginning.
- Look into the
Makefile for the JarType
example, for a complete example.
Ileana Streinu