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
If we wanted to call the runnable file prog we would have to type
cc prog.c func1.c func2.c
In these examples, each of the .c files is compiled, and then they are automatically linked together using a program called the loader ld.
cc prog.c func1.c func2.c -o prog
No comments:
Post a Comment