A template that generates a dynamic-link library:
1 #######################2 # Makefile3 #######################4 5 # Compile and lib parameter6CC: = g++7LIBS: =8Ldflags: =9Defines: =TenINCLUDE: =-I. OneCFLAGS: = Acxxflags:= - - # link Parameter the#LIB: =libfunc.so -LIB: =LIBFUNC.A - - #link + $ (LIB): FUNC.O -$ (CC)-shared-o-fpic-o [email protected] $^ + #compile A FUNC.O:THREAD.C at$ (CC)-c-fpic $^-o [email protected] - - # Clean - Clean : -RM-FR *.O
View Code
Two templates for compiling executable programs:
1 ###########################################2#Makefile forSimple Programs3 ###########################################4Inc=5Lib=-Lpthread6 7Cc=GCC8cc_flag=-Wall9 Tenprg=ThreadTest One#OBJ =thread.o cthreadpool.o cthread.o cworkerthread.o threadpooltest.o Aobj=THREAD.O - - $ (PRG): $ (OBJ) the$ (CC) $ (INC)-o [email protected] $ (OBJ) $ (LIB) - - . Suffixes:. C. O cpp - . CPP.O: +$ (CC) $ (cc_flag) $ (INC)-C $*.cpp-o $*. O - + . Prony:clean A Clean : at@echo"removing linked and compiled files ..." -Rm-f $ (OBJ) $ (PRG)
View Code
Test results:
1 Reference Documentation: 7988192
2 Code path: Https://github.com/DyLanCao/iApply/tree/master/c_example/makefile
Linux under a few common makefile templates, pro-Test available