makefile模板

xiaoxiao2021-02-28  21

so库

############################################################# 

# Makefile for shared library. # 编译动态链接库

##############################################################

set your own environment option

CC = g++ CC_FLAG = -D_NOMNG -D_FILELINE #set your inc and lib INC =  LIB = -lpthread -L./ -lsvrtool #make target lib and relevant obj  PRG = libsvrtool.so OBJ = Log.o #all target all:$(PRG) $(PRG):$(OBJ) $(CC) -shared -o $@ $(OBJ) $(LIB) .SUFFIXES: .c .o .cpp .cpp.o: $(CC) $(CC_FLAG) $(INC) -c $*.cpp -o $*.o .PRONY:clean clean: @echo "Removing linked and compiled files......;

rm -f $(OBJ) $(PRG)

静态库

############################################################## Makefile for static library.# 编译静态链接库##############################################################set your own environment optionCC = g++CC_FLAG = -D_NOMNG -D_FILELINE#static library use 'ar' command AR = ar#set your inc and libINC = LIB = -lpthread -L./ -lsvrtool#make target lib and relevant obj PRG = libsvrtool.aOBJ = Log.o#all targetall:$(PRG)$(PRG):$(OBJ) ${AR} rv ${PRG} $?.SUFFIXES: .c .o .cpp.cpp.o: $(CC) $(CC_FLAG) $(INC) -c $*.cpp -o $*.o.PRONY:cleanclean: @echo "Removing linked and compiled files......" rm -f $(OBJ) $(PRG)

可执行文件

############################################Makefile for simple programs###########################################INC=LIB= -lpthreadCC=g++CC_FLAG=-WallPRG=threadpooltestOBJ=CThreadManage.o CThreadPool.o CThread.o CWorkerThread.o threadpooltest.o$(PRG):$(OBJ) $(CC) $(INC) -o $@ $(OBJ) $(LIB)  .SUFFIXES: .c .o .cpp.cpp.o: $(CC) $(CC_FLAG) $(INC) -c $*.cpp -o $*.o.PRONY:cleanclean: @echo "Removing linked and compiled files......" rm -f $(OBJ) $(PRG)

转载请注明原文地址: https://www.6miu.com/read-1750308.html

最新回复(0)