【发布时间】:2013-12-18 15:50:02
【问题描述】:
我有两个基于自动工具的项目 AAA 和 BBB:
- AAA 是用“--enable-static --disable-shared”构建的,所有代码都是用 C 编写的
- BBB 是一个动态库,使用“libBBB_la_LIBADD = /path/to/libAAA.a”链接到 AAA
我在尝试编译 BBB 时得到以下信息:
/usr/bin/ld: /usr/local/lib/libAAA.a(liboAAA_la-foo.o): relocation R_X86_64_PC32 against undefined symbol `malloc@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
作为参考,产生错误的实际命令是:
gcc -shared -fPIC -DPIC .libs/libBBB_la-BBB.o .libs/libBBB_la-hash.o .libs/libBBB_la-vl_helpers.o -lm -L/usr/local/lib /usr/local/lib/libAAA.a -O3 -Wl,-soname -Wl,libBBB.so.0 -o .libs/libBBB.so.0.0.0
我做错了什么,我该如何做?
【问题讨论】:
标签: c linker ld autotools libtool