Skip to main content

15.7) Exercise 25


  1. Check that you have the ‘make’ build tool installed by entering the command make. If you get a ‘No targets specified’ error, you can continue with Step 2 below; otherwise, you may need to install it yourself.
  2. Create a file called Makefile containing rules to build the program from Exercise 24. Use the compiler commands from that exercise. Be sure to put a single tab character in front of each command and make sure that the rule in the file is the one that links object code files to create the final executable.
  3. Enter make again. If you have implemented the rules correctly, all four compiler commands will run and an executable will be generated.
  4. Make a trivial change to one of the .cpp files. Save your changes, then enter make once more. This time, only two commands should run: the command to compile the changed file into object code and the command to link all of the object code into an executable.