There is the following hierarchy in the working directory:
config (directory) main.cpp Makefile Makefile contents in working directory:
main: main.o g++ -Wall -std=c++1y main.o ./config/load_config.o -o main main.o: config/load_config.o g++ -Wall -std=c++1y -o main.o -c main.cpp clean: rm *.o in the config directory is:
load_config.cpp load_config.h Makefile config / Makefile content
load_config.o: load_config.cpp g++ -Wall -std=c++1y -o load_config.o -c load_config.cpp clean: rm *.o if the working directory is config, then config / Makefile runs without errors. As a result, we have the file config / load_config.o . Make cd ../ After that, run make in the main directory of the program is going fine. But if there is no config / load_config.o , then the program is no longer going. The question is how to change the main Makefile so that it first executes make in the config folder ( build config / load_config.o )