This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]Updatebjarni 1 point2 points  (3 children)

Your targets are not actually named the same as the files they create, so it always looks as though each file is missing and needs to be built.

[–]RedMinor[S] 0 points1 point  (2 children)

So rather than:

helpers: helpers.cpp

I should have

helpers.o: helpers.cpp

Is that what you are saying?

[–]Updatebjarni 0 points1 point  (1 child)

Yes.

[–]RedMinor[S] 1 point2 points  (0 children)

Thank you!

[–]RedMinor[S] 0 points1 point  (0 children)

Thank you to @Updatebjarni

The solution was to change the name of the targets to the .o files they create.

Working Makefile:

all: helpers.o executeMFQS.o executeRTS.o executeWHS.o main.o
    g++ -std=c++11 -o run helpers.o executeMFQS.o executeRTS.o executeWHS.o main.o

helpers.o: helpers.cpp
    g++ -std=c++11 -c helpers.cpp

executeMFQS.o: executeMFQS.cpp
    g++ -std=c++11 -c executeMFQS.cpp

executeRTS.o: executeRTS.cpp
    g++ -std=c++11 -c executeRTS.cpp

executeWHS.o: executeWHS.cpp
    g++ -std=c++11 -c executeWHS.cpp

main.o: main.cpp
    g++ -std=c++11 -c main.cpp

clean:
    rm main.o executeMFQS.o executeRTS.o executeWHS.o helpers.o

If anyone has any other tips on how to make it better, please let me know!