2015-11-02 85 views
1

我試圖執行與我自己的庫編譯的程序,但是當我執行程序我得到以下錯誤:意外RELOC類型×03

./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 

我attatch我的圖書館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) 

回答

1

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,但也許不是構建共享庫時。

+1

謝謝!我發現我正在靜態鏈接'-lpthread',我改變了它的動態鏈接,並從鏈接器中刪除了'-fPIC',並且它非常完美! –