Have you ever wondered how gcc turns C code into the 1s and 0s running on a microcontroller? This guide aims to give you a high-level understanding of that process so you’re better equipped to debug build issues.
This presentation goes over the entire build process, from pre-processing to linking. By the end, you should understand (at a high level) how a C program (source + header file) gets converted into a single executable binary.
Note that this presentation doesn’t cover the following:
https://docs.google.com/presentation/d/12lLWlmoqqt9IyqFMw2rRkrKlP7ss1a_KW3gRZiMJzRE/edit?usp=sharing
You can try this demo to see the different outputs of each stage in the build process.
https://github.com/UWOrbital/build-process-workshop
Create a GitHub codespace
In the terminal on the codespace, you can try the following commands and view the output files.
These commands stop the build process after the pre-processing stage:
gcc -E main.c -Iinc -o outputs/main.i
gcc -E src/example.c -Iinc -o outputs/example.i
These commands stop the build process after the compilation process: