make之链接静态库
(1)方法一: 指定静态库全路径和全名
APP_S_LIBS += ./app_lib/libhost.a
$(CC) $(CFLAGS) $(SRCOBJ) $(APP_S_LIBS) -o $(TARGET)
APP_HEAD_DIR += -I./include
#APP_LIBS_DIR += -L ./app_lib#APP_S_LIBS += -lhost
APP_S_LIBS += ./app_lib/libhost.aCFLAGS += $(APP_HEAD_DIR)
CFLAGS += $(APP_LIBS_DIR)
CFLAGS += -Wall -O2
CFLAGS += -fstack-protector-all
include makefile.configTARGET = test_pro
SRCMAIN = ./main.c
SRC_DIR += $(SRCMAIN)
SRCOBJ = $(patsubst %.c,%.o,$(SRC_DIR))$(TARGET):$(SRCOBJ)$(CC) $(CFLAGS) $(SRCOBJ) $(APP_S_LIBS) -o $(TARGET)%.o: %.c$(CC) $(CFLAGS) -c $< -o $@clean:$(RM) $(SRCOBJ) $(TARGET)
cc -I./include -Wall -O2 -fstack-protector-all -c main.c -o main.o
cc -I./include -Wall -O2 -fstack-protector-all ./main.o **./app_lib/libhost.a** -o test_pro
(2)方法二 -L 指定库路径 -I指定库名 需要去掉lib和.a
#AR =
#CC =APP_HEAD_DIR += -I./include
APP_LIBS_DIR += -L ./app_libAPP_S_LIBS += -lhostCFLAGS += $(APP_HEAD_DIR)
CFLAGS += $(APP_LIBS_DIR)
CFLAGS += -Wall -O2
CFLAGS += -fstack-protector-all
include makefile.configTARGET = test_pro
SRCMAIN = ./main.c
SRC_DIR += $(SRCMAIN)
SRCOBJ = $(patsubst %.c,%.o,$(SRC_DIR))$(TARGET):$(SRCOBJ)$(CC) $(CFLAGS) $(SRCOBJ) $(APP_S_LIBS) -o $(TARGET)%.o: %.c$(CC) $(CFLAGS) -c $< -o $@clean:$(RM) $(SRCOBJ) $(TARGET)
cc -I./include -L ./app_lib -Wall -O2 -fstack-protector-all -c main.c -o main.o
cc -I./include -L ./app_lib -Wall -O2 -fstack-protector-all ./main.o -lhost -o test_pro