asg4
for instance) as the files that need to
be compiled and linked to generate the final executable
program.
CC -c -I. -I/usr/include/ -I/usr/include/CC/ -o timer.o timer.c CC -c -I. -I/usr/include/ -I/usr/include/CC/ -o arr.o arr.c CC asg4.c timer.o arr.o -o asg4 CC test.c timer.o arr.o -o testYou can see above that the Makefile first seperately compiled the modules
timer.c
, then arr.c
,
then linked timer.o
, arr.o
,
and asg4.c
into the executable asg4
.
The Makefile then re-used timer.o
and
arr.o
to compile and link with test.c
to generate the executable test
.
Filename | Contents |
arr.h |
Array class interface (that is,
just the class definition) |
arr.c |
Array class implementation (that is,
just the code for the class member
functions)---needs to
#include "arr.h" at top |
timer.h |
Timer class interface |
timer.c |
Timer class implementation---needs
to #include "timer.h" at
top |
test.c |
Tester program to test array class (that is,
just the main() routine to
use and ``exercise'' the array class. |
asg4.c |
Assignment 4 program to test solution |
test.c
and asg4.c
programs need to #include "arr.h"
and
asg4.c
needs to also
#include "timer.h"
.
#include
files, and, in general, which files
need which other files to function properly. This ``need''
is referred to as a dependency. For example, the
program file asg4.c
uses, or depends on, the
information in arr.h
and timer.h
,
and (indirectly) also on the information in arr.c
and arr.c
. These, in turn, also depend on
arr.h
and timer.h
. This is
shown in the graphic below. The Makefile is used to express
these dependencies, and it uses this information to manage the
compilation and linking of all these related files to generate
the final executable programs.