[try Beta version]
Not logged in

 
makefile doesn't work perfectly

Nov 17, 2016 at 6:57am
I am programming in c++ on linux.
I have a program with 5 c++ files an tried to compile them with a "makefile" to avoid all the repetitions and time wast coming from that.
however, it doesn't really work.
I am new in this field, is it possible to get advice about this content?
makefile
1
2
3
4
5
6
7
8
9
10
StoreSimulator: StoreSimulator.cpp HardwareStore.h 
	g++ -o StoreSimulator StoreSimulator.cpp HardwareStore.o Shopper.o ShoppingCart.o Item.o
HardwareStore.o: HardwareStore.h HardwareStore.cpp Shopper.h Item.h
	g++ -c HardwareStore.cpp
Shopper.o: Shopper.h Shopper.cpp ShoppingCart.h Item.h
	g++ -c Shopper.cpp
ShoppingCart.o: ShoppingCart.h ShoppingCart.cpp Item.h
	g++ -c ShoppingCart.cpp
Item.o: Item.h Item.cpp
	g++ -c Item.cpp
Last edited on Nov 17, 2016 at 6:57am
Nov 17, 2016 at 1:54pm
I think you should create a target for StoreSimulator.o and use that file instead of StoreSimulator.cpp when building the StoreSimulator target. There is no reason why you should handle StoreSimulator.cpp any different from the other source files.

The dependencies for the StoreSimulator target should be the .o files.
Last edited on Nov 17, 2016 at 2:02pm
Nov 18, 2016 at 2:52pm
yes, it worked. thank you !
Topic archived. No new replies allowed.