linux: 几个常用makefile模板
2024-08-20 04:56:00
不才,总结个人常用makefile模板,以备后用。
1、编译动态库
- #############################################################
- # 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)
2、编译静态库
- #############################################################
- # Makefile for static library.
- # 编译静态链接库
- #############################################################
- #set your own environment option
- CC = g++
- CC_FLAG = -D_NOMNG -D_FILELINE
- #static library use 'ar' command
- AR = ar
- #set your inc and lib
- INC =
- LIB = -lpthread -L./ -lsvrtool
- #make target lib and relevant obj
- PRG = libsvrtool.a
- OBJ = Log.o
- #all target
- all:$(PRG)
- $(PRG):$(OBJ)
- ${AR} rv ${PRG} $?
- .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)
3、可执行程序
- ###########################################
- #Makefile for simple programs
- ###########################################
- INC=
- LIB= -lpthread
- CC=CC
- CC_FLAG=-Wall
- PRG=threadpooltest
- OBJ=CThreadManage.o CThreadPool.o CThread.o CWorkerThread.o threadpooltest.o
- $(PRG):$(OBJ)
- $(CC) $(INC) $(LIB) -o $@ $(OBJ)
- .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
最新文章
- vs2010 安装mvc3
- rsync permission denied created directories have no permissions
- Getaddrinfo()笔记
- 重新想象 Windows 8 Store Apps (62) - 通信: Socket TCP, Socket UDP
- table 锁定表头,出滚动对齐
- Shell函数参数
- Windows7如何在安全模式下卸载驱动(亲测)
- 用nginx做代理服务器上网
- 时间类处理<;1>;
- 关于debug和release 以及new 和delete
- Day2:T4求逆序对(树状数组+归并排序)
- Java语言写出水仙花数,
- PHP和MySQL Web开发学习笔记介绍
- MongoDB学习--安装与管理
- django xadmin 1不在可用的选项中
- Java 多线程(一)—— 概念的引入
- 第五节:Task构造函数之TaskCreationOptions枚举处理父子线程之间的关系。
- Fiddler工具使用介绍
- 百度统计api 关于搜索引擎返回参数问题
- 终于把eShopOnContainer部署成功了。