What happens when you type gcc main.c?

Example of when using gcc

The compilation has 4 stages
The compilation process comprises four successive stages: preprocessing, compilation, assembly, and linking. To go from a human-written source program to an executable file, you need to perform these four steps in a row. The gcc commands are capable of doing the whole process in one go.

1. Preprocessed.

At this stage the directives to the preprocessor are interpreted. Among other things, variables initialized with #define are substituted in code for their value in all places where their name appears.
As we saw in the first image we have a file point c at the moment of putting gcc “File.c” creates a new file called a.out
Here we already see the second stage, which is the Compilation.
The compilation transforms the C code into the assembly language of the processor of our machine. What is to place Gcc “File.c”
performs the first two stages creating the file already called a.out you can see the program in assembly language.
Already having the file that is created after executing gcc comes the third phase of the stage that is the Assembler that transforms the program written in assembly language into object code, a binary file in machine language executable by the processor.

Example of when the file created by the gcc command is executed

Already in this last phase that we have left is Linked
The C functions included in our code, such as puts in the example, are already compiled and assembled in existing libraries on the system. It is necessary to incorporate somehow the binary code of these functions to our executable. This is the linking stage, where one or more modules are put together in object code with the existing code in the libraries.
In other words, it is when the file is executed to know if that code that we write works. As we can see in the image, the file is executed as a file as shown in the image above this text.