makefile

当前目录下所有.cpp文件编译为-o文件
最后生成main.exe

CXX=g++
TARGET=main
SRC=$(wildcard *.cpp)
OBJ=$(patsubst *.cpp ,-o ,$(SRC))
CXXFLAGS=-c -Wall

$(TARGET):$(OBJ)
	$(CXX) -o $(TARGET) $(OBJ)

%.o:%.cpp
	$(CXX) $(CXXFLAGS) $< -o $@

clean:
	del *.o $(TARGET).exe
posted @ 2023-03-08 11:46  对CSDN使用炎拳吧  阅读(15)  评论(0编辑  收藏  举报