The sequence of commands executed by a single invocation of GCC consists of the following stages:
As an example, we will examine these compilation stages individually using the Hello World program hello.c:
#include <stdio.h> int main (void) { printf ("Hello, world!\n"); return 0; }
Note that it is not necessary to use any of the individual commands described in this section to compile a program. All the commands are executed automatically and transparently by GCC internally, and can be seen using the -v option described earlier (see Verbose compilation). The purpose of this chapter is to provide an understanding of how the compiler works.
Although the Hello World program is very simple it uses external header files and libraries, and so exercises all the major steps of the compilation process.