Compilation and Execution Process of C Programs
This section describes steps of the compilation and execution process of C programs: preprocessing, compilation, assembly, linking and loading.
The compilation and execution process of C can be divided in to multiple steps:
- Preprocessing - Using a Preprocessor program to convert C source code in expanded source code.
"#includes" and "#defines" statements will be processed and replaced actually source codes in this step.
- Compilation - Using a Compiler program to convert C expanded source to assembly source code.
- Assembly - Using a Assembler program to convert assembly source code to object code.
- Linking - Using a Linker program to convert object code to executable code.
Multiple units of object codes are linked to together in this step.
- Loading - Using a Loader program to load the executable code into CPU for execution.
Here is a simple table showing input and output of each step in the compilation and execution process:
Input Program Output
source code > Preprocessor > expanded source code
expanded source code > Compiler > assembly source code
assembly code > Assembler > object code
object code > Linker > executable code
executable code > Loader > execution
Here are examples of commonly used programs for different compilation and execution steps on a Linux system:
- "cpp hello.c -o hello.i" - Preprocessor preprocessing hello.c and saving output to hello.i.
- "cc1 hello.i -o hello.s" - Compiler compiling hello.i and saving output to hello.s.
- "as hello.s -o hello.o" - Assembler assembling hello.s and saving output to hello.o.
- "ld hello.o -o hello" - Linker linking hello.o and saving output to hello.
- "load hello" - Loader loading hello and running hello.
Table of Contents
About This Book
2002 - .NET Framework Developed by Microsoft
1995 - PHP: Hypertext Preprocessor Created by Rasmus Lerdorf
1995 - Java Language Developed by Sun Microsystems
1991 - WWW (World Wide Web) Developed by Tim Berners-Lee
1991 - Gopher Protocol Created by a University of Minnesota Team
1984 - X Window System Developed a MIT Team
1984 - Macintosh Developed by Apple Inc.
1983 - "Sendmail" Mail Transfer Agent Developed by Eric Allman
1979 - The Tcsh (TENEX C Shell) Developed by Ken Greer
1978 - Bash (Bourne-Again Shell) Developed by Brian Fox
1978 - The C Shell Developed by Bill Joy
1977 - The Bourne Shell Developed by Stephen Bourne
1977 - Apple II Designed by Steve Jobs and Steve Wozniak
1976 - vi Text Editor Developed by Bill Joy
1974 - Internet by Vinton Cerf
►1972 - C Language Developed by Dennis Ritchie
What Is C Language
TCC - Tiny C Compiler
►Compilation and Execution Process of C Programs
GNU C Compiler
Sample C Program for Arrays and Pointers
Sample C Program for Dynamic Memory Allocation - malloc()
1971 - FTP Protocol Created by Abhay Bhushan
1970 - UNIX Operating System Developed by AT&T Bell Labs
1957 - FORTRAN Language Developed by IBM
Full Version in PDF/EPUB