What happens when you type gcc main.c?

Carolina Andrea Capote
2 min readFeb 11, 2021

--

First, we should know what gcc means. GCC stands for GNU Compiler collection and it is a collection of compilers developed for some programming languages to compile programs and generate executable files that the computer can read and understand.

The compile’s process has multiple models, where a task is executed. Next, we can see a diagram with the parts of the compilation that we’ll explain.

Preprocessor

In this part of the process, we already wrote a C file before and the preprocessor removes the comments of this C file and adds the header files.

Compiler

The compiler takes the file and generates an intermediate file called the Assembly code (file.s). This file.s is still not understood by the machine.

Assembler

Here, the gcc converts the Assembly code (file.s) into the object code. This last code is the one that the machine can understand and read. If you didn’t know yet, the object code is is a binary code (a list of some 1 and 0) because the machines can just read this kind of code.

Linker

This is the last module of our process. Here, the linker will link the libraries of functions we used into our code and it will generate the executable file.

When we finish this process, we will have a C program that the computer can run. Remember, there are more different compilers that you can use, not only gcc but we usually use it to work with C language.

--

--