我有几个使用共享库的程序。这些共享库依次使用各种标准 C 库。IE
程序 A 和程序 B 都使用共享库 S。共享库 S 使用标准 C 数学。我希望能够将共享库 S 与标准库静态链接,然后将程序 A 和 B 与 S 静态链接,这样我就不必在库文件中拖拽,因为这些程序将在运行 BusyBox 0.61 的嵌入式系统。但是,当我尝试将程序静态链接到共享库 S 时,我从 GCC 收到一条错误消息,指出:
../lib/libgainscalecalc.a(gainscalecalc.): In function 'float2gs':
[path to my C file].c:73: undefined reference to 'log'
有人可以帮我吗?我正在使用的 make 命令如下:
CFLAGS += -Wall -g -W
INCFLAGS = -I$(CROSS_INCLUDE)/usr/include
LIBFLAGS += -L$(CROSS_LIB)/usr/lib -lm
gainscalecalc_static.o: gainscalecalc.c
$(CC) $(CFLAGS) -c $< -I. $(INCFLAGS) -o $@
gainscalecalc_dynamic.o: gainscalecalc.c
$(CC) $(CFLAGS) -fPIC -c $< -o $@
all: staticlib dynamiclib static_driver dynamic_driver
clean:
$(RM) *.o *.a *.so *~ driver core $(OBJDIR)
static_driver: driver.c staticlib
$(CC) $(CFLAGS) -static driver.c $(INCFLAGS) $(LIBFLAGS) -I. -L. -lgainscalecalc -o $@
dynamic_driver: driver.c dynamiclib
$(CC) $(CFLAGS) driver.c -o $@ -L. -lgainscalecalc
staticlib: gainscalecalc_static.o
$(AR) $(ARFLAGS) libgainscalecalc.a gainscalecalc_static.o
$(RANLIB) libgainscalecalc.a
chmod 777 libgainscalecalc.a
dynamiclib: gainscalecalc_dynamic.o
$(CC) -shared -o libgainscalecalc.so gainscalecalc_dynamic.o
chmod 777 libgainscalecalc.so
编辑:链接共享库编译得很好,我只是还没有测试出来