I'm having issues with rule B in my Makefile. I would like to be able to call make B
to compile my project, but I get a large error message because it doesn't detect the .o files generated by the dependencies. However, it is able to detect the .o files from the first call when I call it again, and it works fine.
I tried printing the .o files with make say
while in make B
, and it printed all the files I expected it to. But when I ran the inline version of make say
right below, it printed nothing, suggesting to me that somehow it is not detecting the .o files in the context of the rule.
Additionally, calling make A
after cleaning results in success, but I feel this defeats the point of having dependencies in the first place.
GPP = g++
VER = -std=c++17
A: Profile.o AllProfiles
make B
B: Profile.o AllProfiles
make say # Prints all .o files
echo $(wildcard ./*.o) # Prints nothing
$(GPP) -o ProfileList $(wildcard ./*.o) ProfileList.cpp $(VER)
AllProfiles:
$(GPP) -c $(wildcard src/profiles/*.cpp) $(VER)
Profile.o: Profile.cpp
$(GPP) -c Profile.cpp $(VER)
say:
echo $(wildcard ./*.o)