我正在尝试将静态库链接到共享库,我收到了以下错误
/usr/bin/ld: ../../../libraries/log4cplus/liblog4cplus.a(fileappender.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC ../../../libraries/log4cplus/liblog4cplus.a: could not read symbols: Bad value collect2: ld returned 1 exit status
但这适用于32位机器而没有任何此类错误.我尝试-fPIC手动将标志添加到Makefile,但也没有解决问题
我-whole-archive按照这里的建议尝试了旗帜,但没有成功.
/usr/bin/ld: ../../../libraries/log4cplus/liblog4cplus.a(appenderattachableimpl.o): relocation R_X86_64_32S against `vtable for log4cplus::spi::AppenderAttachable' can not be used when making a shared object; recompile with -fPIC ../../../libraries/log4cplus/liblog4cplus.a(appenderattachableimpl.o): could not read symbols: Bad value collect2: ld returned 1 exit status
unzip log4cplus-1.1.0.zip./configure --enable-static=yes …在gcc(g ++)下,我编译了一个静态.a(调用它some_static_lib.a)库.我想把这个.a文件链接(这是正确的短语?)到libsomeDyn.so我正在构建的另一个动态库(称之为).虽然.so编译,我看.a不到.so使用nm命令的内容:
/ usr/bin/g ++ -fPIC -g -O2 -Wall -Werror -pipe -march = pentium3 -mtune = prescott -MD -D_FILE_OFFSET_BITS = 64 -DLINUX -D_GNU_SOURCE -D_THREAD_SAFE -I ../../../. ./../../../../ -I ../../../../../../../..// libraries -Wl,-rpath,/ usr/lib -o libsomeDyn.so some.o another.o some_static_lib.a -shared -Wl -x -Wl,-soname,libsomeDyn.so
我看不到功能some_static_lib.a不足libsomeDyn.so.我究竟做错了什么?
我有一堆静态库(*.a),我想构建一个共享库(*.so)来链接这些静态库(*.a).我怎么能用gcc/g ++这样做?
我正在尝试在 Ubuntu Linux 上使用 g++ 5.4.0 创建一个共享库。
我已经构建了 Poco C++ 库的静态库(.a 文件),我想将它们静态链接到我的共享库中。
但它不起作用。
我已将以下字符串添加到我的构建脚本中:
-Wl,-whole-archive -lPocoFoundation -Wl,-no-whole-archive
Run Code Online (Sandbox Code Playgroud)
g++ 抱怨以下错误消息:
relocation R_X86_64_32S against '-ZTVN4Poco15ArchiveStrategyE' can not be used when making a shared object; recompile with -fPIC
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?