Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




11.1 An overview of the compilation process

The sequence of commands executed by a single invocation of GCC consists of the following stages:

  • preprocessing (to expand macros)
  • compilation (from source code to assembly language)
  • assembly (from assembly language to machine code)
  • linking (to create the final executable)

As an example, we will examine these compilation stages individually using the Hello World program 'hello.c':

#include <stdio.h>

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 section 9.3 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.

  Published under the terms of the GNU General Public License Design by Interspire