cversion = -std=c++23 -D_GNU_SOURCE -I src/include
#Folder and Path
dotO = ./src/dotO
SRC = ./src
manmade = manmade
test = test
output.exe: $(dotO)/$(manmade)/message.o $(dotO)/$(manmade)/allo.o main.o
g++ $(cversion) $^ -o $@
main.o: main.cpp
g++ $(cversion) -c $^ -o $@
$(dotO)/$(manmade)/message.o: $(SRC)/$(manmade)/message.cpp
g++ $(cversion) -c $^ -o $@
$(dotO)/$(manmade)/allo.o: $(SRC)/$(manmade)/allo.cpp
g++ $(cversion) -c $^ -o $@
$(dotO)/$(test)/test.o: $(SRC)/$(test)/test.cpp
g++ $(cversion) -c $^ -o $@
$(dotO)/$(test)/test2.o: $(SRC)/$(test)/test2.cpp
g++ $(cversion) -c $^ -o $@
也许还有其他,但我不明白这一点:
来自 @HardcoreHenry 问题的代码:如何在特定文件夹中创建 .o 文件 - Makefile?
OBJ_DIR := folder
SRCS := main.cpp message.cpp
//I do not understand this part(OBJS)
OBJS := $(patsubst %.cpp,$(OBJ_DIR)/%.o,$(notdir $(SRCS))
$(info Note: OBJS is $(OBJS))
output.exe: $(OBJS)
g++ $(cversion) $(OBJS) -o $@
//I do not understand this part.
$(OBJS) : $(OBJ_DIR)/%.o : %.cpp
g++ $(cversion) -c $< -o $@
你能解释一下顶部的代码是做什么的吗?
OS : Windows
Text Editor : VScode
I am using mingw64 and I run the Makefile with MinGW32-make