Quiz 4 content/topics and preparation
Quiz 4 will focus on makefiles and compilation in the context of C++ programs.
The quiz will be a two-hour VIULearn quiz, available 5pm Wed. the 6th to 1pm Monday the 18th.
It is open book, open notes, but must still be a strictly individual exercise: no help may be requested
or accepted from anyone other than the instructor, and the quiz content cannot be discussed with anyone
other than the instructor until after 1pm on the 18th. The use of AI products to generate answers,
in whole or in part, is similarly not permitted.
(Note: the quiz questions are the same ones as for the original 50-minute in-class format,
but I've extended the timeline to two hours to accommodate any technical hassles surrounding
VIULearn.)
You will be provided with a description of two programs and their
overlapping structure of .h, .cpp, and .o files, then asked four questions
relating to this structure.
The format of each of the four questions is provided below.
Note the comment in question 3 about the use of complex patterns in your makefile:
I don't want people trying to memorize and apply makefile patterns they really don't
understand. (Show me that you understand the fundamentals: don't try to get fancy in
a quiz question.)
Question 1 [2 marks]: sketch a dependency graph
Sketch a dependency graph for the .h and .cpp files above (with arrows going from the file containing
the #include to the file being included) and add the .o files (with arrows from them to their .cpp file)
and the two executables (with arrows from them to the .o's they use).
Question 2 [2 marks]: manually updating .o's and executables
Assuming both executables and all the .o's were up to date then I edited SOME COMBINATION OF FILES,
show the precise sequence of g++ commands I would need to run to rebuild the minimal correct set of
.o and executables (i.e. don't do any unnecessary compilations, but ensure everything that needs to
be updated does get updated).
Use SOME OPTIONS LIST as the chosen set of options with each of your compilations
(in addition to -c's and -o's as needed).
Question 3 [5 marks]: writing a makefile
Provide a makefile that correctly rebuilds the correct but minimal set of .o's and executables
in response to any file edits, with targets for each .o, each executable, and an 'all' target
to do any necessary rebuilds of both executables. The makefile must also obey the following restrictions:
- it declares and consistently uses a variable for the compiler options
- it appropriately uses the $^ and $@ variables throughout
I strongly recommend you do not use any rule patterns/substitution rules (beyond
the three specified variables).
If you choose to do so then you must clearly and correctly explain precisely how each such rule is resolved into each intended target, dependencies, and build commands.
Failing to do so will result in no credit for that portion of the makefile.
Question 4 [3 marks]: showing your makefile results
Given the makefile you provided in question 3, if all the .o's and executables were up to date
then I edited SOME COMBINATION OF FILES and then typed 'make all', show the precise sequence of
g++ commands the makefile would run as a result.
If you know your makefile does not correctly rebuild the correct set of files then also
provide a list identifying which of the needed re-compilations it currently fails to perform.