一、Linux:
1.下载linuxdeployqt工具
$ chmod +x linuxdeployqt-x86_64.AppImage
$ mv linuxdeployqt-x86_64.AppImage linuxdeployqt
$ mv linuxdeployqt /usr/local/bin
$ linuxdelpoyqt --version
#输出的版本信息
linuxdeployqt 5 (commit 37631e5), build 631 built on 2019-01-25 22:47:58 UTC
2.配置Qt环境
ubuntu环境下:
修改用户环境变量,在终端执行vim ~/.bashrc
进行编辑
#add QT ENV
export PATH=/opt/Qt5.7.0/5.7/gcc_64/bin:$PATH
export LD_LIBRARY_PATH=/opt/Qt5.7.0/5.7/gcc_64/lib:$LD_LIBRARY_PATH
export QT_PLUGIN_PATH=/opt/Qt5.7.0/5.7/gcc_64/plugins:$QT_PLUGIN_PATH
export QML2_IMPORT_PATH=/opt/Qt5.7.0/5.7/gcc_64/qml:$QML2_IMPORT_PATH
注:/opt/Qt5.15.1/5.15 为Qt安装目录,根据自己安装路径改动
配置后,执行source ~/.bashrc
立即生效。
如果失败:
./linuxdeployqt-6-x86_64.AppImage: /opt/Qt5.7.0/5.7/gcc_64/lib/libQt5Core.so.5: version `Qt_5.9' not found (required by ./linuxdeployqt-6-x86_64.AppImage)
# 错误可能还有其他的,有些问题 可以用下面的方面解决:
unset QTDIR ; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
# 参考链接来自:https://www.cnblogs.com/linuxAndMcu/p/11016322.html
3.打包
linuxdelpoyqt 程序名 -appimage
4.参考链接
https://www.cnblogs.com/linuxAndMcu/p/11016322.html Build on old systems, run on newer systems: https://docs.appimage.org/introduction/concepts.html#build-on-old-systems-run-on-newer-systems
中标麒麟环境下:
- 生成.exe环境
打开Qt项目,选择release方式,点击运行
此时,在release目录下可看到生成的.exe程序 - 使用windeployqt自动复制dll
打开cmd,进入 .exe所在的文件夹, 输入windeployqt.exe *.exe。此时项目名称.exe同目录下多出一些dll文件,再双击项目名称.exe即可正常运行。