64位系統下連接靜態庫報錯:“could not read symbols: Bad value”的解決辦法


公司來了新服務器(64位系統),將項目從原來的服務器(32位)上遷移過去后,編譯出錯:

g++     -shared -o dist/Debug/GNU-Linux-x86/libGeoFlock.so -fPIC build/Debug/GNU-Linux-x86/GeoFlock.o build/Debug/GNU-Linux-x86/library.o build/Debug/GNU-Linux-x86/GeoCrawler.o http://www.cnblogs.com/framework/jasgreen/dist/Debug/GNU-Linux-x86/libjasgreen.a 
/usr/bin/ld: http://www.cnblogs.com/framework/jasgreen/dist/Debug/GNU-Linux-x86/libjasgreen.a(properties.o): relocation R_X86_64_32 against `__gxx_personality_v0' can not be used when making a shared object; recompile with -fPIC
http://www.cnblogs.com/framework/jasgreen/dist/Debug/GNU-Linux-x86/libjasgreen.a: could not read symbols: Bad value
collect2: ld returned 1 exit status

 

經分析,是我的項目引用了一個靜態庫:“libjasgreen.a”,在連接該庫的時候出錯了,提示“can not be used when making a shared object”。

解決辦法為:“recompile with -fPIC”。很簡單:使用 -fPIC選項重新編譯一下libjasgreen.a即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM