GUN makefile

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 16:19   1312   0

标准c工程makefile

CC  := g++
C_FLAGS := -std=c++17 -Wall -Wextra -g

BIN  := bin
SRC  := src
INCLUDE := include
LIB  := lib

LIBRARIES :=

ifeq ($(OS),Windows_NT)
EXECUTABLE := main.exe
else
EXECUTABLE := main
endif

all: $(BIN)/$(EXECUTABLE)

clean:
 $(RM) $(BIN)/$(EXECUTABLE)

run: all
 ./$(BIN)/$(EXECUTABLE)

$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
 $(CC) $(C_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES)

动态库工程

CC  := g++
C_FLAGS := -std=c++17 -Wall -Wextra -g  -fPIC -shared

BIN  := bin
SRC  := src
INCLUDE := include
LIB  := lib

LIBRARIES :=

EXECUTABLE := libtest.so

all: $(BIN)/$(EXECUTABLE)

clean:
 $(RM) $(BIN)/$(EXECUTABLE)

run: all
 ./$(BIN)/$(EXECUTABLE)

$(BIN)/$(EXECUTABLE): $(SRC)/*.cpp
 $(CC) $(C_FLAGS) -I$(INCLUDE) -L$(LIB) $^ -o $@ $(LIBRARIES)

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP