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相关的库,而是因为以上库冲突报错才需要指定特定目录下面的库。

重新构建,运行正常。

 

posted on 2020-07-28 16:51  苦涩的茶  阅读(3259)  评论(1编辑  收藏  举报

// 1.生成目录索引列表