class: title # Makefiles and Multifile Projects ## CSC 161 – February 24, 2026 --- # Agenda for Today 1. Upcoming Work 2. Discussion 3. Lab 4. Wrap Up --- class: section blue # Upcoming Work --- # Week 6 Quiz As usual, we'll have a quiz on Thursday. The quiz will last 10 minutes, and will focus on: 1. Unsigned Integer Representation 2. Two's Complement Signed Integer Representation 3. Compiling Multifile Projects 4. Makefile Rules Topics from Thursday's reading will not appear on this week's quiz, but please make sure you still read to prepare for our lab. --- # Homework: Connect Four **Due:** Thursday, February 26th ## Questions _None so far_ If you need to work on the assignment from off campus you can access a MathLAN session by going to
. --- class: section blue # Discussion --- # Discussion: Multifile Projects **Items for think, pair, share:** 1. What happens when you write `#include` in a C source file? 2. We generally put function implementations in source files rather than header files. Why do you think that is? 3. The following commands compile two source files to object files, then combine them into a single program: ```shell clang -c source1.c clang -c source2.c clang -o program source1.o source2.o ``` What is a single command that would do all these steps, and why might we prefer the three-command version? --- # Discussion: Makefiles **Items for think, pair, share:** 1. Why do we use `make` and `Makefile`s? 2. Consider the following `Makefile` rule: ```make game: game.c interface.h interface.c ai.h ai.c clang -o game game.c interface.c ai.c ``` - What is the *target* in the rule above, and what does it mean? - What is the *recipe* in the rule above, and what does it mean? - What are the *prerequisites* in the rule above, and what do they mean? --- class: section blue # Lab --- class: section blue # Wrap Up --- # Wrap Up ## Lab Work Submit your completed *Farm Simulator* program with a working `Makefile` as part of your lab report for this week. You can submit the `Makefile` you produce in part B or any later part of the `Makefile` lab. ## Reading - **Testing** - **Beej's Quick Guide to gdb**