Makefile 连接静态库注意事项

CC = gcc
#CFLAGS =  -I. -I/sbilling/charging/src/lib/ -D_REENTRANT -g -I/usr/include/mysql/

#LZIBS = -L. -lm -L/usr/lib64/mysql/ -lmysqlclient -L/sbilling/charging/src/lib/ -ldci
CFLAGS =  -I. -I/usr/include/mysql/ -I/sbilling/charging/src/lib/
LZIBS = -L. -lm -lnsl -g -L/usr/lib64/mysql/ -lmysqlclient -L/sbilling/charging/src/lib/ -ldci
COMPILE = ${CC} ${CFLAGS}
MAKEEXE = ${CC}


BILLINGOBJ = billingmain.o billingutil.o billinginit.o billingdealdata.o billingdb.o billingLogic.o

all:    billapp
billapp:        ${BILLINGOBJ}
                ${MAKEEXE} -o $@ $^ ${CFLAGS} ${LZIBS}

.c.o:
        ${COMPILE} -c $<

clean:

                rm -f *.o core

在这个makefile中,红色行中$^和 CFLAGS 和LZIBS的顺序不能颠倒,否则LZIBS会不起作用。


你可能感兴趣的:(Makefile 连接静态库注意事项)