Linux打包Qt程序及Linux移植过程中出现QSQLITE driver not loaded 的解决办法

xingyun86 2019-12-4 1494

错误信息:

QSqlDatabase: QSQLITE driver not loaded                                        
QSqlDatabase: available drivers:  

解决方案:

export QT_PLUGIN_PATH=/root/testapp/plugins

./testapp

成功!

打包Qt程序

1.1 下载打包工具

#wget https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage

#mv linuxdeployqt-continuous-x86_64.AppImage deployqt

#mv deployqt /usr/bin

#linuxdelpoyqt --version

1.2 打包应用程序

cd /home/test/testapp

deployqt ./testapp -appimage

完成后会有【 testapp、lib目录、plugin目录、translations目录、qt.conf】即可发布。

1.3 添加应用程序图标

auto.desktop文件设置:

#-- 全局安装(所有用户可用),将xxx.desktop 复制到/usr/share/applications  
#-- 当前用户可用, 将xxx.desktop 复制到 ~/.local/share/applications 目录即可
#--appName.desktop
[Desktop Entry]
Version=1.0 #app的版本
Name=testapp #app的名字
Comment= this app use for xxx #说明信息 
Exec=/home/test/testapp #app的执行路径,绝对路径
Icon=/home/test/app_icon/testapp.png #icon 路径,绝对路径
Terminal=false #是否在终端启动,效果自己试一下就知道了
Type=Application
Categories=Utility;Application

1.4 关于qt.conf
这个文件指定了qt 程序的运行环境。
引用qt说明的原话:
The qt.conf file can be used to override the hard-coded paths that are compiled into the Qt library. These paths are accessible using the QLibraryInfo class. Without qt.conf, the functions in QLibraryInfo return these hard-coded paths; otherwise they return the paths as specified in qt.conf.
即我们可以使用qt.conf 指定qt程序的运行路径和库路径。
The file should have a Paths group which contains the entries that correspond to each value of the QLibraryInfo::LibraryLocation enum. See the QLibraryInfo documentation for details on the meaning of the various locations.
这个文件应该要包含QLibraryInfo::LibraryLocation enum,如以下内容
主要有这几个,多余的可以上qt帮助文档

# Generated by linuxdeployqt
# https://github.com/probonopd/linuxdeployqt/
[Paths]
Prefix = ./         #程序的运行路劲
Libraries =  ./lib  #程序的库路径
Plugins = ./plugins #插件路径

参考:http://doc.qt.io/qt-5/qt-conf.html

【打包错误信息及解决】

1.5 如果出现libmysqlclient_r.so.16 not find

链接: https://pan.baidu.com/s/1AKNnq-IDuDe0whN8Cxn82g 提取码: i35a

1.6 如果出现libpq.so.16 not find

debian/ubuntu: apt-get install libpq-dev

centos: yum install postgresql-devel


×
打赏作者
最新回复 (0)
只看楼主
全部楼主
返回