The C Compilation Proccess

Manuel Enrique Figueroa
2 min readSep 16, 2020

GCC:

Linux can use a special compiler called gcc which can compile c code into an execute file. The most basic syntax is (gcc [file_name.c]) but this will print a file named a.out which is probably not what you want.

Here you can see when we used the command with this syntax it output a execute file name a.out

you can use a option for gcc which is -o if you want a specific name for the output file. The syntax for that is (gcc [file_name.c] -o [execute_file_name].

The PreProccessor:

C code begins its proccess of being understood by you machine at the PreProccessor stage. During this stage our PreProccessor searches our code for directives which essentialy will tell our next step (the compiler) how to proccess the output(basically seperating the actuall code from the input). The command (gcc -E [file_name] ) that can print out the preproccessor stage of the compilation proccess in a new file with a (.i) extension of the same name as the input file.

The Compilation:

This step converts our preproccessor output into assembly instructions for the assembly step. As before you can isolate the output of this step by using a gcc command (gcc -S [file_name]) which will output a file of the same name with the file extension (.s)

The assembly:

This step converts the assembly instcrutions provided by the compilation proccess into what known as object code. This steps output actually creates binary instructions (machine language) to be run by the current machine. You can isolate this step by using the gcc command (gcc -c [file_name]) with a file extensions of (.o) or (.obj). However this step leaves out static librarys and object files left over from the proccess

The Linking:

This step takes the leftover static library and object files along with the object code created from the assembly step outputting the final executible file=.

--

--

Manuel Enrique Figueroa
0 Followers

I am a current student at Holberton school of software engineering aspiring to have a career in full stack software engineering.