makefile doesn't work perfectly

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
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
yes, it worked. thank you !
Topic archived. No new replies allowed.