Compiling Multiple Files
Build a multi-file program.
From Source to Program
Turning multi-file C source into an executable happens in two stages: compiling and linking.
Each .c file is compiled separately into an object file. Then the linker combines all object files, resolving references between them, into one runnable program.
The One-Command Build
The simplest approach hands every source file to gcc at once. The compiler builds each, then links them automatically.
The -o flag names the output program. List all .c files; headers are pulled in via #include and are not listed here.
gcc main.c math_utils.c -o appAll lessons in this course
- Header and Source Files
- Include Guards
- extern and Linkage
- Compiling Multiple Files