小编Thi*_*jan的帖子

"重定位R_X86_64_32S反对"链接错误

我正在尝试将静态库链接到共享库,我收到了以下错误

/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

创建liblog4cplus.a:

  1. unzip log4cplus-1.1.0.zip
  2. ./configure --enable-static=yes …

c++ linux shared-libraries static-libraries

54
推荐指数
2
解决办法
9万
查看次数

为什么在运行时更改LD_LIBRARY_PATH dosen一旦Executable被加载就反映在Executable上

我正试图改变LD_LIBRARY_PATH我的C++程序.我能够使用它来获取它的值getenv("LD_LIBRARY_PATH")并使用它设置它的值setenv()(我知道这是有效的,因为当我getenv("LD_LIBRARY_PATH")再次调用时,我得到更新的值),但是从程序内部改变它的值没有任何影响对它:我仍然收到此错误消息:

Failed to Load the shared library file

如果我在加载可执行文件或启动应用程序之前设置了值,它就可以正常工作.

c++ linux setenv getenv

7
推荐指数
1
解决办法
2659
查看次数

标签 统计

c++ ×2

linux ×2

getenv ×1

setenv ×1

shared-libraries ×1

static-libraries ×1