建立一個Makefile檔案,把下面内容拷過去,項目裡直接用make指令就okay
make
make clean
CC = g++
CFLAGS = -pthread
TARGET = TEST
DIRS = .
FILES = $(foreach dir, $(DIRS), $(wildcard $(dir)/*.cpp))
OBJS = $(patsubst %.cpp, %.o, $(FILES))
TARGETNAME := TEST
$(TARGET):$(OBJS)
$(CC) -o $(TARGET) $(OBJS) $(CFLAGS)
$(OBJS):%o:%cpp
$(CC) -c $< -o [email protected] $(CFLAGS)
clean:
-$(RM) $(TARGET) $(OBJS)