GCC COMPILER

¿What happens when you type gcc main.c?

Adrian Felipe Vides Jimenez
2 min readSep 21, 2020

First of all we need to understand what we are typing, so let’s see.

“gcc” is the the GNU Compiler Collection and it includes front ends for C, C++, Objective-C, Fortran, Ada, Go, and D, as well as libraries for these languages

In the process of compiling are involved 4 steps: Preprocessing, Compiler, Assembler and Linking. And now let’s see what do these steps do:

Preprocessing:

In this step the directives are interpreted to the preprocessor. Here the compiler takes the source code and remove comments indicated by /**/ or #

Compiler:

In this step the file code is taken and turned it into assembly code, so the in the next step Assembler can read it

Assembler:

The assembler takes the assembly code and turned it into an object code (machine language) which is in binary.

Linking:

In this final steps all code is linked together in a single executable file, which if there is no specified name, it will be called “a.out”.

This is a graphical explanation.

So now that you know what is gcc you may know what “gcc main.c” does.

Yeah, “gcc main.c” will compile (go trough all 4 steps) and create a new executable file with the code inside the file “main.c”

Before you go, if you want to name that new file you have to add <-o> and the name you want, for example:

If you want to know more about this you can check here and search more information.

--

--

Adrian Felipe Vides Jimenez
Adrian Felipe Vides Jimenez

Written by Adrian Felipe Vides Jimenez

I'm a Software Developer passionate by programming, videogames and music. Nowadays studying at Holberton School

No responses yet