The Linker

OK, so I lied slightly about the complexity of the process. In reality there are even more steps than just writing a C program in a text editor and compiling it with a compiler. But if you are lucky, the extra steps, which I am now going to describe, will be pretty much invisible to you, for now at least.

Firstly, in some cases your program may be quite large, and so may consist of more than one part. Therefore, a standard compiler rarely produces an executable file directly, but may stop at an intermediate step (other than the assembly language possibility mentioned above). It will produce what are called object files. These can be thought of as machine code files that have loose ends waiting to be joined up with other loose ends.

Each part of your program is turned into one of these object files, and each object file contains not only the machine code instructions for that part of the program, but a set of rules for linking this object file with other object files, and even references to parts of itself.

In order to turn this series of object files into an executable program, one uses a linker. The linker joins up all the loose ends and resolves the absolute location within the final program of all the relative references included within the object files.

In addition to the compilation and linking steps, sometimes there are so many parts to your program that you need an additional file, called a project file or make file, to keep track of them all. This project or make file specifies all the different parts of your program. It tells the compiler which files to compile into object files. Then it tells the linker which object files to link together into the final executable program.

Well, I lied earlier for a reason. I'm not trying to confuse you on page one! Basically, for the moment, you don't need to know about linkers, debuggers, project files or any other additional steps which may occur when programming. For now, you only need to know how to write in the C language using a text editor, and how to use a C compiler so that you can turn your written C program into an executable which you can run.