¿What happens when you type gcc main.c?

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.

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Drupal 8 core and Symfony components

Zero to Hero in Python in 30 days: Day 10: Functions Part II

🦸‍♂️Vote for Edufex 🧛 💥It’s time to boost Edufex token value to the skies by voting.☄️

Is your boss making random decisions?

7 Ground Breaking Software Development Outsourcing Trends for 2020

iOS Development Part — 6

Brush your concepts about Non-Disclosure Agreements (NDA) for Mobile & Web Application Development…

Python: Everything is an object

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian Felipe Vides Jimenez

Adrian Felipe Vides Jimenez

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

More from Medium

Pen #003: The Hacker Methodology

Alfred Pennyworth and Barbara Gordon from Batman

Beginners Guide to Self-Learning Windows and Active Directory: Part 1

PNPT v. OSCP — What You Should Know

HackTheBox-Pandora