Makefiles I am writing a program to manage the inventory of

Makefiles

I am writing a program to manage the inventory of animals at a pet store. So far, I\'ve written

two classes — Dog and Cat — and a main program called pet_store.cpp. Each of the

pet classes consists of a header (.h) file and an implementation (.cpp) file.

Consider the following makefile:

1 CPPFLAGS = -ansi -Wall

2

3 pet_store: pet_store.o Dog.o Cat.o

4     g++ pet_store.o Dog.o Cat.o -o pet_store

5

6 pet_store.o: pet_store.cpp Dog.h Cat.h

7     g++ -c pet_store.cpp

8

9 Dog.o: Dog.cpp Dog.h

10 g++ -c Dog.cpp

11

12 Cat.o: Cat.cpp Cat.h

13 g++ -c Cat.cpp

What is the name of the executable program that will be produced when the makefile is processed?

For the rule on lines 6 and 7, what are the dependencies?

For the rule on lines 12 and 13, what is the recipe?

For the rule on lines 9 and 10, what is the target?

What is the meaning of the \"-c\" flag on lines 7, 10, and 13?

Solution

The name of the executable program that will be produced when the makefile is processed is pet_store.

6 pet_store.o: pet_store.cpp Dog.h Cat.h

7     g++ -c pet_store.cpp

Here the dependencies are : pet_store.cpp, Dog.h, Cat.h

12 Cat.o: Cat.cpp Cat.h

13 g++ -c Cat.cpp

Here recipe is -c

9 Dog.o: Dog.cpp Dog.h

10 g++ -c Dog.cpp

Here the target is Dog.o

The meaning of the \"-c\" flag on lines 7, 10, and 13 is that -c flag says to generate the object file.

Makefiles I am writing a program to manage the inventory of animals at a pet store. So far, I\'ve written two classes — Dog and Cat — and a main program called
Makefiles I am writing a program to manage the inventory of animals at a pet store. So far, I\'ve written two classes — Dog and Cat — and a main program called

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site