debug運行報錯解決:symbol __cxa_throw_bad_array_new_length version Qt_5 not defined in file libQt5Gui.so.5 with link time reference


Ubuntu18.04系統下,為使用restful,加入cpprestsdk(sudo apt-get install libcpprest-dev)后qt debug運行報錯:(可執行目錄加上各種依賴庫后,可直接正常運行)

15:49:41: Starting /home/***/***Server/***Server...
/home/***/***Server/***Server: relocation error: /home/***/***Server/***Server: symbol __cxa_throw_bad_array_new_length version Qt_5 not defined in file libQt5Gui.so.5 with link time reference
15:49:42: /home/***/***Server/***Server exited with code 127

經過多方查找、分析(網絡搜索),問題應該出在系統中同一個庫在多個目錄下有多個版本,造成沖突引起的。

(參考文章:https://blog.csdn.net/carry1beyond/article/details/54880861;https://blog.csdn.net/kakaxi2222/article/details/46820509;https://blog.csdn.net/qq_24963323/article/details/82344408)

本項目報錯的原因最后發現應該是 Qt libstdc++-6.dll引起的。

 

 由於本項目報錯情況與參考文章中剛好相反,是debug運行報錯,執行目錄運行正常,故應該在qt的pro文件中指定libstdc++庫的路徑,如下:

本項目需要的cpprestsdk需要在pro中添加如下庫

INCLUDEPATH +=/usr/include/openssl
INCLUDEPATH +=/usr/include/cpprest/
LIBS+=-L/usr/lib/x86_64-linux-gnu/ -lcpprest -lssl -lcrypto -lstdc++   # -lboost_system -lboost_thread -lboost_chrono(#部分的庫也是需要的,由於在其它項目中已經存在故注釋,實際情況按需添加)

注:-lstdc++原來不是cpprestsdk相關的庫,而是因為以上庫沖突報錯才需要指定特定目錄下面的庫。

重新構建,運行正常。

 


免責聲明!

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



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