Qt安装程序打包记录


Qt安装程序打包记录

文章目录

    • Qt安装程序打包记录
  • 1.Qt安装程序制作的工具
  • 2.安装程序生成步骤
    • 2.1 QIFW的下载和安装
    • 2.2 Qt程序打包
    • 2.3 安装程序制作
  • 3.一些问题记录

1.Qt安装程序制作的工具

​ Qt官方提供了Qt Installer Framework工具制作安装程序,下面会简称QIFW。

​ Qt Installer Framework框架提供了一组工具和实用程序,用于创建一次安装程序,并在所有受支持的桌面Qt平台上部署它们,而无需重写源代码。安装程序将在运行它们的平台上具有本机外观:Linux,Microsoft Windows和OS X。

​ QIFW提供了在线安装和离线安装两种方法:

Qt安装程序打包记录_第1张图片

2.安装程序生成步骤

2.1 QIFW的下载和安装

​ 需要从官方网址现在QIFW对应版本,官方地址:http://download.qt.io/official_releases/qt-installer-framework/

​ 如网速太慢可以前往阿里,清华,中科大镜像地址下载,自行搜索。
Qt安装程序打包记录_第2张图片
​ 安装时选择接受许可即可,安装过程无障碍,不做记录。

2.2 Qt程序打包

​ 首先需要再release模式下编译程序,生成release版本,即发布版本。再release文件夹下可以找到可执行文件.exe,将可执行文件复制到一个空文件夹内,如F:\zhangfan。

​ 使用Qt自带的打包工具windeployqt对程序打包,把一些Qt的库或者依赖项添加进行来,可以在没安装Qt的电脑上使用exe,如果使用了Qt以外的第三方库,需要把第三方库的依赖项添加进去。打开windows命令行界面Qt 6.2.1 (MSVC 2019 64-bit),并执行操作,以onlyFoZhangFan.exe为例:

f: # 进入f盘符
cd zhangfan # 进入zhangfan目录
windeployqt onlyFoZhangFan.exe # 打包
Qt安装程序打包记录_第3张图片
Qt安装程序打包记录_第4张图片

最后需要手动加入所有第三方的依赖和库文件。

2.3 安装程序制作

​ 首先需要创建一个包目录结构,该包目录结构必须包含名为config和packages的子目录。config包含了有关如何构建安装程序二进制文件和联机存储库的信息,packages包含有关可安装组件的信息,结构如下图所示。不过QIFW安装目录下面有很多的示例,拿startmenu来示范,复制一份出来。startmenu的一般路径F:\Qt Installer Framework\examples\startmenu。

Qt安装程序打包记录_第5张图片

​ 接下来需要把3.2中打包的所有文件复制再packages下的data目录中(所有和onlyFoZhangFan.exe同级的文件)。

​ 修改文件配置(未使用)

​ 接下来打开Qt 6.2.1 (MSVC 2019 64-bit)命令行工具,进入复制的目录F:\startmenu,运行binarycreator.exe进行安装程序生成:

f:
cd startmenu
binarycreator.exe -c config/config.xml -p packages 安装程序名称.exe -v

​ 等待安装程序生成,此处只运行binarycreator.exe可以看到参数选择的帮助列表。

​ 下面是输出信息:

F:\startmenu>binarycreator.exe -c config/config.xml -p packages zhangfan.exe -v
[0] Parsed arguments, ok.
[2] Collecting information about available packages...
[3] Found subdirectory "org.qtproject.ifw.example"
[4] - it provides the package "org.qtproject.ifw.example"  -  "1.0.0-1"
[5] Copying component data for "org.qtproject.ifw.example"
[8] Compressing data directory "iconengines"
[20] Compressing data directory "imageformats"
[184] Compressing data directory "platforms"
[292] Compressing data directory "styles"
[316] Compressing data directory "translations"
[902] Compressing files found in data directory: ("F:/startmenu/packages/org.qtproject.ifw.example/data/D3Dcompiler_47.dll", "F:/startmenu/packages/org.qtproject.ifw.example/data/onlyFoZhangFan.exe", "F:/startmenu/packages/org.qtproject.ifw.example/data/opengl32sw.dll", "F:/startmenu/packages/org.qtproject.ifw.example/data/Qt6Core.dll", "F:/startmenu/packages/org.qtproject.ifw.example/data/Qt6Gui.dll", "F:/startmenu/packages/org.qtproject.ifw.example/data/Qt6Svg.dll", "F:/startmenu/packages/org.qtproject.ifw.example/data/Qt6Widgets.dll", "F:/startmenu/packages/org.qtproject.ifw.example/data/README.txt")
[8833] Hash is stored in "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1iconengines.7z.sha1"
[8836] Creating hash of archive "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1iconengines.7z"
[8838] Generated sha1 hash: "8818b65c3a507207fca8799cdbd36b0efab5fc7c"
[8839] Hash is stored in "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1imageformats.7z.sha1"
[8841] Creating hash of archive "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1imageformats.7z"
[8844] Generated sha1 hash: "6cdd3f7b61966f33ad0051b1bc643d45daee5630"
[8846] Hash is stored in "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1platforms.7z.sha1"
[8847] Creating hash of archive "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1platforms.7z"
[8850] Generated sha1 hash: "efe5dea0e70112760302aeee2720986a24350940"
[8851] Hash is stored in "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1styles.7z.sha1"
[8853] Creating hash of archive "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1styles.7z"
[8855] Generated sha1 hash: "f09eeba8c38c8caf2c993a7c1806827cf28cf429"
[8857] Hash is stored in "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1translations.7z.sha1"
[8859] Creating hash of archive "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1translations.7z"
[8863] Generated sha1 hash: "c51150480fc0c0a976e3870c53fde5202fe184a9"
[8864] Hash is stored in "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1content.7z.sha1"
[8866] Creating hash of archive "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1content.7z"
[8892] Generated sha1 hash: "1504f85bbb862ed0cfb1cda3bf5c18052865ffae"
[8894] Copy meta data for package "org.qtproject.ifw.example" using "packages/org.qtproject.ifw.example/meta/package.xml"
[8896] calculate size of directory "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/data"
[8905] Copying associated "script" file "packages/org.qtproject.ifw.example/meta/installscript.qs"
[8908] done.
[8910] Begin to copy configuration file and data.
[8911] Copying associated "configuration" file "F:/startmenu/config/config.xml"
[8914] done.
[8914] Read dom element: <Name>Start Menu Shortcut Example</Name>.
[8917] Read dom element: <Version>1.0.0</Version>.
[8918] Read dom element: <Title>Start Menu Shortcut Example</Title>.
[8919] Read dom element: <Publisher>Qt-Project</Publisher>.
[8920] Read dom element: <StartMenuDir>Qt Installer Framework Examples</StartMenuDir>.
[8922] Read dom element: <TargetDir>@HomeDir@/IfwExamples/startmenu</TargetDir>.
[8925] done.

[8932] Creating the binary
[9079] Creating resource archive for "org.qtproject.ifw.example"
[9081] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1iconengines.7z" ("22.41 KB")
[9084] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1iconengines.7z.sha1" ("40.00 bytes")
[9086] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1imageformats.7z" ("447.99 KB")
[9089] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1imageformats.7z.sha1" ("40.00 bytes")
[9092] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1platforms.7z" ("259.70 KB")
[9096] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1platforms.7z.sha1" ("40.00 bytes")
[9099] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1styles.7z" ("59.85 KB")
[9103] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1styles.7z.sha1" ("40.00 bytes")
[9105] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1translations.7z" ("615.86 KB")
[9108] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1translations.7z.sha1" ("40.00 bytes")
[9114] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1content.7z" ("11.84 MB")
[9116] Appending "C:/Users/zhang/AppData/Local/Temp/binarycreator-eCWiEv/org.qtproject.ifw.example/1.0.0-1content.7z.sha1" ("40.00 bytes")
[9157] Cleaning up...

F:\startmenu>

​ 至此,F:\startmenu目录中出现zhangfan.exe安装程序,操作结束。

Qt安装程序打包记录_第6张图片

3.一些问题记录

​ 1.过程中自己操作失误没有把打包文件放入data目录中导致生成失败。

​ 2.出现了data目录中某个文件太大导致生成失败。

你可能感兴趣的:(工业视觉,qt,windows)