¿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

Interview with Keynote Speaker Michael Bolton

TryHackMe Snort Challenges Walk-Through by jself970

How Award-Winning Dutch Tech Companies Build Champion Software Teams

Increase Sales With SugarCRM’s Top-Rated Plugins

Setting up CI pipeline with Jenkins, GitHub & Docker on Ubuntu (Linux) machine

Dart in the IoT world — a practical example

Getting Your Computer Ready for Web Programming

Designing for the Operator Experience

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

INCREASE OR DECREASE SIZE OF STATIC PARTITION IN LINUX.

Bash Basics and Navigating Directory Trees

Ansible: Raw vs Command vs Shell Module