Building your Program

Build your program with the following sequence of commands:

     g++ -ansi -Wall -c lab4.cpp
     g++ -ansi -Wall -c Fraction.cpp
     g++ -Wall lab4.o Fraction.o -o lab4

There are two distinct steps in the program build:

  1. lab4.cpp and Fraction.cpp are compiled to produce the object files lab4.o and Fraction.o.
  2. The objects files are linked to produce the executable lab4.

Understanding this explict form of the build process is necessary to be able to write makefiles. Use the makefile template below to write a makefile for the lab (use the file name Makefile). If your makefile is correct, typing the command


will execute the makefile and build your program.

Note: Indentation in makefiles must use a tab, not multiple spaces.

CPPFLAGS = -ansi -Wall

lab4: lab4.o Fraction.o
     g++ lab4.o Fraction.o -o lab4

lab4.o: lab4.cpp Fraction.h

Fraction.o: WHAT GOES HERE...
     AND HERE?