Qt程序各個平臺打包發佈及安裝程序大全

本文連接:https://blog.csdn.net/zhengtianzuo06/article/details/78468111
通用:
1.準備圖標
圖標能夠直接使用通常格式的圖片製做, 好比jpg, png等
推薦使用Photoshop製做原始圖linux


推薦使用IconWorkshop製做圖標, 很是的方便android


Windows和Linux的程序圖標, 製做ico格式圖標web


MacOS製做icns格式圖標sql


Android和IOS直接使用Pngjson

2.準備License文件, readme說明等bash

程序發佈:
1.Windows:websocket

準備程序版權版本等信息app

Qt中圖標及版本信息的設置, 能夠參考我以前的發佈項目例子
QmlVersionInfosocket

Release編譯:svg

選擇項目


選擇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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 未完待續… ———————————————— 版權聲明:本文爲CSDN博主「zhengtianzuo」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連接及本聲明。 原文連接:https://blog.csdn.net/zhengtianzuo06/article/details/78468111

相關文章
相關標籤/搜索