The process of compilation in C files
Compilation is a process by which a programming code is “translated” from a language understood by humans to one understood by machines. In this way, the system can run a program.
The process of compiling a code (in this case, a .c file) is divided into 4 threads. Next, we will detail what they are.
The first step in compiling a c file is that the c code is preprocessed. Within the code, the comments are eliminated and all the code, its properties and the header files that are used begin to be detailed. In addition, an intermediate .i file is created whose output is the preprocessed code. The process so far looks like this:
The next step is to compile the preprocessed file into assembly language. Then a new .s file will be created whose content is the following:
So what continues is the assembly of the new .s file (with the assembly language code) to pass it to machine code, which will generate a .o file with the following content:
Finally, the machine code file is converted to a machine-executable binary file. This thread is called linking.
These 4 threads can also be summarized in the following command:
gcc <file> .c –o <file>
After that, the file is ready to run on any machine with the system that supports the compiler.
Sources:
https://es.wikibooks.org/wiki/Programaci%C3%B3n_en_C/C%C3%B3mo_compilar_un_programa
https://es.wikibooks.org/wiki/Programaci%C3%B3n_en_C/El_proceso_de_compilaci%C3%B3n
https://www.javatpoint.com/compilation-process-in-c
https://programmerclick.com/article/1868742319/
https://linux.die.net/man/1/gcc