What happens when you compile your first file in C
The C programming language is a widely-used imperative computer programming language that must use a compiler. C provides low-level access to memory. The description “low-level” refers to the language’s distance to the machine language of ones and zeros. Many popular languages such as Python, Ruby, Java, and JavaScript are build on the fundamentals of the C language. I happen to like learning Romance languages, so I tend to think of C as the Latin of computer languages.
Because of this low-level nature, programs written in C need to go through a compiler, which involves four steps: Preprocessing, Compiling, Assembly, and Linking.
Preprocessing
The preprocessor generates an intermediate file that is ready for assembly. This takes out any commented language, includes header files in the source code, and replaces macro names with code. A file is generated after this process.
Compiling
At the compiling stage, the preprocessed language is converted to assembly language, which are still English words and mnemonics.
Assembly
The assembler then converts the assembly code to object code, which is in binary format. Several files of object codes are generated after this process.
Linking
The files generated are made of machine instructions, but are out of order. To make an executable file, these files need to be rearranged and instructions for library functions will be added, then finally packaged into an executable file.
The Gnu Compiler Collection (GCC) is the standard compiler for most Unix systems, and is free, thanks to the Free Software Foundation.
If you want to try seeing the four stages of compiling for yourself, follow the steps, as I outlined above in more detail, from Calle Erlandsson.