Exercise: Compiling a Multifile Program
Say we have a program that consists of four .cpp files:
cow.cpp
barn.cpp
chicken.cpp
farm.cpp
Now say we make a change in chicken.cpp
but leave the rest of the files the same.
Key Ideas:
- We need to compile each
.cpp
file into a.o
file, then one more command to link them together to create the executable. - When we change a file, we only need to recompile that one file and then re-link. This is another advantage to splitting up our program—we only need to compile parts of our program that change.
Okay, we've got a chunk done, let's head up to the parent page to see our progress and take a break!
(When logged in, completion status appears here.)