c++ - 意外的重定位类型 0x03

标签 c++ g++ raspberry-pi shared-libraries

我正在尝试执行一个用我自己的库编译的程序,但是当我执行该程序时出现以下错误:

./a.out 
./a.out: error while loading shared libraries: ../../lib-arm/libCustomLibrary.so: unexpected reloc type 0x03

发布执行时会发生这种情况,调试执行时一切正常。

您认为这可能是哪里的问题?

CustomLibrary 库与以下参数链接:

-lSubLibrary -fPIC -Wl,-Bstatic -lboost_system -lboost_filesystem -lboost_thread -lpthread -Wl,-Bdynamic -lrt

我为我的库附加了 lld unix 库命令输出。

ldd ../../lib-arm/libCustomLibrary.so 
/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so (0x76e5d000)
libSubLibrary.so => ../../lib-arm/libSubLibrary.so (0x76e2d000)
librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76e10000)
libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x76d3e000)
libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76ccd000)
libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x76ca5000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76b75000)
libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76b6a000)
libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76b4b000)
/lib/ld-linux-armhf.so.3 (0x76f05000)

最佳答案

来自 https://lists.linaro.org/pipermail/linaro-toolchain/2012-November/002939.html :

Relocation type 3 is R_ARM_REL32 which is a static relocation not allowed in shared objects. How did you create the shared lib? Make sure you compile all the code going into it with -fPIC.

换句话说,您在链接程序时使用了 -fPIC,但在构建共享库时可能没有使用。

关于c++ - 意外的重定位类型 0x03,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33474070/

相关文章:

c++ - IplImage 在 openCV C++ 中打开图像

c++ - vector 的核心段错误

c++ - 以下代码的符合 ISO C++ 标准的结果

c++ - 在 Crypto++ 库中找不到 hkdf.h

linux - startx 后自动运行脚本

raspberry-pi - 如何制作树莓派 2 laravel 5.1 服务器

c++ - C++中的抽象类声明

c++ - 抽象类是否有 VTABLE?

c++ - 在 C++ 中退出最顶层的递归函数

image-processing - Raspberry Pi 在运行 OpenCV 时变得无响应