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

16 篇文章 0 订阅

转自: http://blog.csdn.net/zhengtianzuo06/article/details/78468111

通用: 
1.准备图标 
图标可以直接使用一般格式的图片制作, 比如jpg, png等 
推荐使用Photoshop制作原始图 
这里写图片描述

推荐使用IconWorkshop制作图标, 非常的方便 
这里写图片描述

Windows和Linux的程序图标, 制作ico格式图标 
这里写图片描述

MacOS制作icns格式图标 
这里写图片描述

Android和IOS直接使用Png

2.准备License文件, readme说明等

程序发布: 
1.Windows:

准备程序版权版本等信息

这里写图片描述

Qt中图标及版本信息的设置, 可以参考我之前的发布项目例子 
QmlVersionInfo

Release编译: 
这里写图片描述 
选择项目

这里写图片描述 
选择Release编译

这里写图片描述 
生成好的目录

这里写图片描述 
清除多余的中间文件

qt提供了专门的部署工具, windeployqt:

Usage: windeployqt [options] [files]
Qt Deploy Tool 5.9.0

The simplest way to use windeployqt is to add the bin directory of your Qt
installation (e.g. <QT_DIR\bin>) to the PATH variable and then run:
  windeployqt <path-to-app-binary>
If ICU, ANGLE, etc. are not in the bin directory, they need to be in the PATH
variable. If your application uses Qt Quick, run:
  windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>

Options:
  -?, -h, --help            Displays this help.
  -v, --version             Displays version information.
  --dir <directory>         Use directory instead of binary directory.
  --libdir <path>           Copy libraries to path.
  --plugindir <path>        Copy plugins to path.
  --debug                   Assume debug binaries.
  --release                 Assume release binaries.
  --pdb                     Deploy .pdb files (MSVC).
  --force                   Force updating files.
  --dry-run                 Simulation mode. Behave normally, but do not
                            copy/update any files.
  --no-patchqt              Do not patch the Qt5Core library.
  --no-plugins              Skip plugin deployment.
  --no-libraries            Skip library deployment.
  --qmldir <directory>      Scan for QML-imports starting from directory.
  --no-quick-import         Skip deployment of Qt Quick imports.
  --no-translations         Skip deployment of translations.
  --no-system-d3d-compiler  Skip deployment of the system D3D compiler.
  --compiler-runtime        Deploy compiler runtime (Desktop only).
  --no-compiler-runtime     Do not deploy compiler runtime (Desktop only).
  --webkit2                 Deployment of WebKit2 (web process).
  --no-webkit2              Skip deployment of WebKit2.
  --json                    Print to stdout in JSON format.
  --angle                   Force deployment of ANGLE.
  --no-angle                Disable deployment of ANGLE.
  --no-opengl-sw            Do not deploy the software rasterizer library.
  --list <option>           Print only the names of the files copied.
                            Available options:
                             source:   absolute path of the source files
                             target:   absolute path of the target files
                             relative: paths of the target files, relative
                                       to the target directory
                             mapping:  outputs the source and the relative
                                       target, suitable for use within an
                                       Appx mapping file
  --verbose <level>         Verbose level.

Qt libraries can be added by passing their name (-xml) or removed by passing
the name prepended by --no- (--no-xml). Available libraries:
bluetooth concurrent core declarative designer designercomponents
enginio gui qthelp multimedia multimediawidgets multimediaquick network nfc
opengl positioning printsupport qml qmltooling quick quickparticles quickwidgets
script scripttools sensors serialport sql svg test webkit webkitwidgets
websockets widgets winextras xml xmlpatterns webenginecore webengine
webenginewidgets 3dcore 3drenderer 3dquick 3dquickrenderer 3dinput geoservices
webchannel texttospeech serialbus

Arguments:
  [files]                   Binaries or directory containing the binary.
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

使用非常的方便, 命令行cd到程序的生成目录

windeployqt.exe –qmldir C:\release\QmlVersionInfo QmlVersionInfo.exe

这里演示的是qml程序的打包, 所以带有 –qmldir 参数 内容是指向项目中qml的文件夹路径, 这样可以让Qt识别运行项目里qml文件需要的QtQuick库.

这里写图片描述

这里写图片描述

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

2.Android:

准备程序版权版本等信息

这里写图片描述 
选择项目

这里写图片描述
首先在Build Android APK中创建模板

这里写图片描述
这里可以填写App包名, 程序版本号, SDK版本号, 程序名称等 
点击下面的三个小方块按钮, 分别设置不同分辨率的程序图标

这里写图片描述 
选择Release编译 
Qt提供了专门的部署工具, androiddeployqt: 编译时自动调用 
在生成目录的android-build\bin下可以看到已经生成好的QtApp-debug.apk

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

Release编译: 
这里写图片描述 
选择项目

这里写图片描述 
选择Release编译

这里写图片描述 
生成好的目录

这个时候需要解决依赖库的问题, 我们使用linuxdeployqt 
GitHub地址: linuxdeployqt 
下载源码 并解压使用Qt Creator编译Release版本即可, 生成的应用程序拷贝到bin目录下 
sudo mv linuxdeployqt /usr/local/bin

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

设置Qt的环境变量:

sudo gedit ~/.bashrc
 
 
  • 1

加上

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
 
 
  • 1
  • 2

让其生效

source ~/.bashrc
 
 
  • 1

然后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 it
self-contained by copying in the Qt libraries and plugins that
the application uses.
 
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

例如: 
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

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值