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
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
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>

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 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