2016年12月13日 星期二

Makefile 在不同的資料夾下做Make,share libary編譯使用

如果你們沒有將share libary 名字取對  libthread_pool.so
則會有下面錯誤訊息
/usr/bin/ld: cannot find -lname



BUILDDIR:=$(CURDIR)/C-Thread-Pool-master
TAR:=$(CURDIR)/../../tarballs/C-Thread-Pool-master.zip
SHARE_LIB_THREAD_POOL:=libthread_pool.so
include ../Makefile.xtool
STRIP=$(CROSS_COMPILE)strip --strip-unneeded

# Rules
all: $(BUILDDIR)/.build

install: all
install -m 755 $(SHARE_LIB_THREAD_POOL) $(ROOTDIR)/lib/

clean:
[ ! -d $(BUILDDIR) ] || rm -rf $(BUILDDIR)
rm -rf $(SHARE_LIB_THREAD_POOL)

$(BUILDDIR)/.tar:
unzip $(TAR)
touch $@

$(BUILDDIR)/.build: $(BUILDDIR)/.tar  $(BUILDDIR)/thpool.c $(BUILDDIR)/thpool.h
$(TARGETCC) -pthread -shared -fPIC -o $(SHARE_LIB_THREAD_POOL) $(BUILDDIR)/thpool.c $(BUILDDIR)/thpool.h
$(STRIP) $(SHARE_LIB_THREAD_POOL)
touch $@

.PHONY: all clean install





調用:
LIBS_PATH = -L/home/jimmychen/work/git/ws/fs3000/trunk/packages/c-thread_pool

had: had.c
$(CROSS_COMPILE)gcc -lpthread -lthread_pool $(LIBS_PATH) -o had had.c

沒有留言:

張貼留言