How do you compile C code? How do you make executable programs from C source code files? This tutorial outlines the basic C compilation model and processes that address those questions. You will better understand how to make the executable file from C source code files.
The following picture illustrates the C compilation model.

Let’s examine each component in more detail.
- The input of the C compilation process is a C source code file, and its result is an executable file. The output of the previous component is the input of the next component.
- The preprocessor uses the source code as input. The preprocessor removes all the comments and interprets preprocessor directives indicated by the hash
#
sign. For example, in the hello world program, the#include
directive is used to include the code of the corresponding file, e.g., standard I/O file,stdio.h
. The preprocessor will include the source code in thestdio.h
file in the main program before transferring it to the compiler. - After the preprocessor processes the source, it transfers the result to the C compiler. The C compiler is responsible for translating plain source code into assembly code. We are using the GCC compiler to translate C code into assembler code.
- The assembler is in charge of creating object code. On Windows systems, the object code files have
.obj
extension, and on UNIX systems, the object code file has.o
extension. - If in the source code file, you use functions from a library, the link editor will combine these functions with the
main()
function to make an executable file of the program. The link editor is sometimes also known as the linker.
The compilation process seems lengthy. Compiling a program yourself takes time and requires more effort. However, with a good IDE like CodeBlocks, you can configure all the components once, and the IDE will handle the tasks automatically with a push of a button.
Was this tutorial helpful ?