Qt程序各个平台打包发布及安装程序大全

Linux:需要解决依赖库的问题, 我们使用linuxdeployqt

GitHub地址: linuxdeployqt
下载源码 并解压使用Qt Creator编译Release版本即可, 生成的应用程序拷贝到bin目录下
sudo mv linuxdeployqt /usr/local/bin

下载安装patchelf patchelf-0.9.tar.gz

设置Qt的环境变量:

sudo gedit ~/.bashrc 加上

export PATH=/opt/Qt5.9.2/5.9.2/gcc_64/bin:$PATH
export LD_LIBRARY_PATH=/opt/Qt5.9.2/5.9.2/gcc_64/lib:$LD_LIBRARY_PATH

让其生效

source ~/.bashrc

然后cd到项目生成位置使用linuxdeployqt生成依赖库, 命令格式:Usage: linuxdeployqt app-binary [options]

Options:
   -verbose=<0-3>      : 0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug
   -no-plugins         : Skip plugin deployment
   -appimage           : Create an AppImage
   -no-strip           : Don't run 'strip' on the binaries
   -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries
   -executable=<path>  : Let the given executable use the deployed libraries too
   -qmldir=<path>      : Scan for QML imports to bundle from the given directory, determined by Qt's qmlimportscanner
   -always-overwrite   : Copy files even if the target file exists
   -qmake=<path>       : The qmake executable to use
   -no-translations    : Skip deployment of translations

linuxdeployqt takes an application as input and makes itself-contained by copying in the Qt libraries and plugins that the application uses.例如:

linuxdeployqt QmlVersionInfo -qmldir=/home/tianzuo/Programming/WorkSpace/QmlVersionInfo

这里写图片描述

生成好的目录情况就是这样, 如果程序还需要一些动态库, 插件, 需要自己加入进去.
然后基本就可以使用安装程序进行打包了.

安装程序制作:
1.Windows:

创建桌面和开始菜单快捷方式:
参考我之前写的博文: Qt创建桌面和开始菜单快捷方式

2.Android:
3.IOS:
4.MacOS:
5.Linux:

创建桌面快捷方式:
这里以Ubuntu为背景介绍下,
新建一个*.desktop文件, 内容如下:

[Desktop Entry]
Categories=Development;
Comment[zh_CN]=
Comment=
Exec=/home/tianzuo/Programming/WorkSpace/QmlVersionInfo/QmlVersionInfo
GenericName[zh_CN]=Qt
GenericName=Qt
Icon=/home/tianzuo/Programming/WorkSpace/QmlVersionInfo/logo.ico
MimeType=
Name[zh_CN]=QmlVersionInfo
Name=QmlVersionInfo
Path=
StartupNotify=true
Terminal=false
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=owen

---------------------  
作者:zhengtianzuo  
来源:CSDN  
原文:https://blog.csdn.net/zhengtianzuo06/article/details/78468111

猜你喜欢

转载自blog.csdn.net/CLP_CSDNID/article/details/83267935