Qt程序运行报错

报错内容

PC环境为Ubuntu20.04,Qt版本是Qt5.12.9AsensingViewer是编译好的程序

./AsensingViewer: error while loading shared libraries: libicudata.so.56: cannot open shared object file: No such file or directory

问题分析

查看程序依赖

ldd AsensingViewer

注意到有个库not found

libicudata.so.56 => not found

cmake配置

link_directories("/opt/Qt5.12.9/5.12.9/gcc_64/lib")

但问题依旧,于是乎设置环境变量,./AsensingViewer成功

export LD_LIBRAR_PATH="/opt/Qt5.12.9/5.12.9/gcc_64/lib"

问题解决,但怎么实现一劳永逸?在家目录.bashrc文件末尾加入一行代码

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/opt/Qt5.12.9/5.12.9/gcc_64/lib"

注意事项

设置了.bashrc环境变量会导致qtcreator运行报错然后崩溃

 (qtcreator:3781): GLib-CRITICAL **: 19:42:15.563: g_hash_table_contains: assertion 'hash_table != NULL' failed  ​ (qtcreator:3781): GLib-CRITICAL **: 19:42:15.563: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed  Segmentation fault (core dumped)

运行前记得刷新一下LD_LIBRARY_PATH,让qtcreator自己找依赖

export LD_LIBRARY_PATH=""  /opt/Qt5.12.9/Tools/QtCreator/bin/qtcreator

或者直接在.bashrc文件加入以下内容,然后两种变量设置就可以完美共存

alias qtcreator='export LD_LIBRARY_PATH="" && /opt/Qt5.12.9/Tools/QtCreator/bin/qtcreator'
阅读剩余
THE END