1

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)
Quinn
  • 81
  • 1
  • 4
  • Can you add the source tree to your post? I see a possible error in AllProfiles creating .o-files in src/profiles directory, and then try read the .o-files from current working directory. Don't take this the wrong way but this makefile look unsalvagable; there are more flaws than lines. With the source tree I could wrap something up in no time. – Andreas Jun 08 '20 at 20:00

0 Answers0