Anytime you want to compile your C code into an executable, you will find yourself using the gcc command. This gcc command initialized the C compiler, taking your human readable code and giving you an executable binary file that executes commands and functions on your machine. The gcc compiler does this in 4 different steps.
First the code goes through the preprocessor. The preprocessor preps your C code before going into the actual compiler. It’s like the seasoning in your recipe. One function of the preprocessor is finding the #include files you have added, grabs their code, and actually puts it into your program instead of just referencing it. At this point it’s still human readable but slightly more confusing!
Secondly the code is compiled. This step takes your human readable code and translates it into Assembly. Assembly is still technically human readable. In fact many early machines depended on Assembly and it’s just one step up from Binary!
Third, the assembler stage takes the Assembly code and translates it into object code. This object code contains machine instructions.
And lastly, the linker. The linker takes all the machine instructions and blocks of object code and orders it into the correct place — providing you with a fluid executable program!
An interesting way to try to observe the compiling process is using these 3 arguments. Take your program (we’ll use main.c for this example) and run it through the gcc compiler in chronological order: -E, -S, and -c
You can then view each file individually and see how they work!