我正在尝试将静态库链接到共享库,我收到了以下错误
/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 …我正试图改变LD_LIBRARY_PATH我的C++程序.我能够使用它来获取它的值getenv("LD_LIBRARY_PATH")并使用它设置它的值setenv()(我知道这是有效的,因为当我getenv("LD_LIBRARY_PATH")再次调用时,我得到更新的值),但是从程序内部改变它的值没有任何影响对它:我仍然收到此错误消息:
Failed to Load the shared library file
如果我在加载可执行文件或启动应用程序之前设置了值,它就可以正常工作.