Next: Separate Compilation Up: Programs with Several Previous: Organisation of Data

Compiling Multi-File Programs

This process is rather more involved than compiling a single file program. Imagine a program in three files prog.c, containing main(), func1.c and func2.c. The simplest method of compilation (to produce a runnable file called a.out) would be

  cc prog.c func1.c func2.c
If we wanted to call the runnable file prog we would have to type

  cc prog.c func1.c func2.c -o prog
In these examples, each of the .c files is compiled, and then they are automatically linked together using a program called the loader ld.
Tue Jan 17 11:40:37 GMT 1995