What happens when you type gcc main.c?

Tadeo Grach
1 min readSep 18, 2020


gcc is the C compiler of choice for most UNIX. The program gcc itself is actually just a front end that executes various other programs corresponding to each stage in the compilation process.


A C file is a source code file for a C or C++ program. And .c is the C file extension.

Steps of compilation

There are 4 steps:


This is the first step, this places all files into your .c file, and it also translates all macros into inline C code.


Compiler convert files genereted by preprocessor as an imput and generetes an assembly code.


Our machine can only read binary, we need to convert the assembly code so the machine can read it. This is what the Assember step does.


This step will link our object code with the library code and generate it exe files.

gcc main.c

So when we type gcc main.c, we are compiling the main.c file and making an executable code.