赞
踩
Qt5可以使用官方的Qt Installer Framework框架制作安装包
Qt Installer Framework框架提供了一组工具和实用程序,用于创建一次安装程序,并在所有受支持的桌面Qt平台上部署它们,而无需重写源代码。安装程序将在运行它们的平台上具有本机外观:Linux,Microsoft Windows和OS X.
安装程序已在以下平台上进行了测试:
- Microsoft Windows XP及更高版本
- Ubuntu Linux 11.10及更高版本
- OS X 10.7及更高版本
使用Qt Installer Framework框架生成的安装程序,其中包含一组页面,可在安装,更新或卸载过程中指导用户。您需要提供安装的内容并指定有关它的信息,例如产品名称和安装程序以及许可协议的文本。
您可以通过向预定义页面添加小部件或添加整个页面来为用户提供其他选项来自定义安装程序。您可以创建脚本以向安装程序添加操作。
选择安装程序类型
根据您的使用情况,您可以为最终用户提供离线或在线安装程序,或两者兼而有之。
两个安装程序都安装了一个维护工具,以后可用于添加,更新和删除组件。离线安装程序包含所有可安装组件,并且在安装期间不需要网络连接。联机安装程序仅安装维护工具,然后从Web服务器上的联机存储库下载和安装组件。因此,在线安装程序二进制文件的大小较小,其下载时间短于脱机安装程序二进制文件的下载时间。如果最终用户未安装所有可用组件,则下载和运行联机安装程序所花费的总时间也可能比下载和运行脱机安装程序的时间短。
最终用户可以在初始安装后使用维护工具从服务器安装其他组件,并在服务器上发布更新后立即接收内容的自动更新。但是,仅当您在脱机安装程序配置中指定存储库地址或最终用户在维护工具设置中指定存储库地址时,这才适用于离线安装。
创建离线安装程序,以使用户能够直接在介质上下载安装包,以便以后在计算机上安装。例如,您也可以将安装包分发到CD-ROM或USB记忆棒上。
创建在线安装程序,使用户始终可以安装最新版本的内容二进制文件。
官方下载:http://download.qt.io/official_releases/qt-installer-framework/
1、选择一个Qt Installer Framework版本,我选择目前最新的3.0.4版本
2、前面两项为压缩包,下载后解压就是一堆文件夹,没有可安装的exe,也没有找到 我们后面要打包的工具binarycreator.exe,所以就选了下面这个可以安装的exe版本,毕竟这个用的顺手。
1、点击运行exe可执行文件,进入Qt Installer Framework设置向导页面,点击“下一步”
2、选择安装路径,最好是新建一个空的文件夹, 用来存放安装的东西,选择完后点击“下一步”
3、进入许可协议页面,选择“我接受这些许可”,要用别人的软件,就必须习惯这个,尊重版权,没得办法,然后点击“下一步”
4、进入到安装页面,直接点击“安装”就好了
1、先要在release模式下编译运行程序,生成release版本,也就是发布版本。在release文件下找到可执行文件exe,默认一般路径:"E:\Qt_Project\build-login-Desktop_Qt_5_11_1_MinGW_32bit-Release\release\music1.exe",如果把修改了项目的默认构建路径为当前项目,那就去当前项目文件里找,例如:"E:\Qt_Project\music1\Release\release\music1.exe",然后新建一个文件夹,把exe复制出来放到空文件夹里。
2、然后使用Qt自带的打包工具windeployqt对应用程序进行打包,其实就是把一些Qt的库或者依赖项添加进行来,可以在没安装Qt的电脑上使用exe,如果使用了Qt以外的第三方库,也需要把第三方库的依赖项添加进去,从电脑左下角的开始菜单打开Qt的命令行界面Qt 5.11.0 for Desktop(MinGW...),输入命令如下:windeployqt C:\Users\欧阳磊\Desktop\Music\music1.exe
3、以下是打包好的文件夹示例,打包好后,点击exe测试一下能否使用,看看是否缺少第三方库或者依赖项,如果点击exe能够正常运行程序,则说明打包成功。
官方文档:http://doc.qt.io/qtinstallerframework/ifw-tutorial.html
1、首先需要创建一个包目录结构,该包目录结构必须包含名为
config
和packages的子目录
。config
包含了有关如何构建安装程序二进制文件和联机存储库的信息,packages
包含有关可安装组件的信息,结构如下图所示。不过Qt Installer Framework安装目录下面有很多的示例,这里就拿startmenu来示范,复制一份出来。startmenu的一般路径D:\QtInstallerFrameworkInstall\examples\startmenu。
2、把前面打包过的文件全部复制到
packages下面的data文件夹里,注意是和exe同一级目录的所有文件。
3、修改配置文件,在
config
目录下,有一个config.xml
文件,使用文本编辑器打开,根据自己的需求进行修改
- <?xml version="1.0" encoding="UTF-8"?>
- <Installer>
- <Name>可乐音乐播放器</Name>
- <Version>1.0.0</Version>
- <Title>音乐播放器安装向导</Title>
- <Publisher>Qt-Project</Publisher>
- <!-- Directory name is used in component.xml -->
- <StartMenuDir>可乐音乐播放器</StartMenuDir>
- <TargetDir>@HomeDir@/可乐音乐播放器</TargetDir>
- </Installer>
- < Name> 软件名称
- < Version> 版本号
- < Title> 安装程序窗口标题
- < Publisher> 发布者名称
- < StartMenuDir> 要生成的windows开始菜单目录
- < TargetDir> 默认安装路径
4、修改包信息文件,在packages
目录下,有一个package.xml文件,使用文本编辑器打开,根据自己的需求进行修改
- <?xml version="1.0" encoding="UTF-8"?>
- <Package>
- <DisplayName>README.txt</DisplayName>
- <Description>A README.txt, accessible through a start menu entry.</Description>
- <Version>1.0.0-1</Version>
- <ReleaseDate>2019-02-19</ReleaseDate>
- <Default>true</Default>
- <Script>installscript.qs</Script>
- </Package>
- < DisplayName> 显示的名称
- < Description> 描述
- < Version> 部件的版本号
- < ReleaseDate> 发行日期
- < Licenses> 许可信息名称以及许可文件名
- <Default>默认是否选中协议
- < Script> 脚本文件
- < UserInterfaces> 额外的界面(如果需要的话,而且需要去installscript.qs中配置)
4、在packages
目录下,有一个installscript.qs文件,使用文本编辑器打开,根据自己的需求进行修改
- /****************************************************************************
- **
- ** Copyright (C) 2017 The Qt Company Ltd.
- ** Contact: https://www.qt.io/licensing/
- **
- ** This file is part of the FOO module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
- ** Commercial License Usage
- ** Licensees holding valid commercial Qt licenses may use this file in
- ** accordance with the commercial license agreement provided with the
- ** Software or, alternatively, in accordance with the terms contained in
- ** a written agreement between you and The Qt Company. For licensing terms
- ** and conditions see https://www.qt.io/terms-conditions. For further
- ** information use the contact form at https://www.qt.io/contact-us.
- **
- ** GNU General Public License Usage
- ** Alternatively, this file may be used under the terms of the GNU
- ** General Public License version 3 as published by the Free Software
- ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
- ** included in the packaging of this file. Please review the following
- ** information to ensure the GNU General Public License requirements will
- ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
- **
- ** $QT_END_LICENSE$
- **
- ****************************************************************************/
-
- function Component()
- {
- // default constructor
- }
-
- Component.prototype.createOperations = function()
- {
- // call default implementation to actually install README.txt!
- component.createOperations();
-
- if (systemInfo.productType === "windows") {
- component.addOperation("CreateShortcut", "@TargetDir@/Music.exe", "@StartMenuDir@/Music.lnk",
- "workingDirectory=@TargetDir@", "iconPath=%SystemRoot%/system32/SHELL32.dll",
- "iconId=2", "description=Open README file");
- }
- }
installscript.qs官方文档链接:http://doc.qt.io/qtinstallerframework/scripting.html
5、添加环境变量,将Qt Installer Framework安装文件下的bin路径添加到环境变量,重启电脑,不会添加自行百度
6、生成安装包程序,打开Qt的命令行界面Qt 5.11.0 for Desktop(MinGW...),输入以下命令,进入要生成的文件夹目录下,然后使用生成工具进行生成安装包应用
- # 输入以下命令进入startmenu目录
-
- D:\Qt5.11\install\5.11.0\mingw53_32>C:
- C:\Windows\System32>cd C:\Users\欧阳磊\Desktop\startmenu
- # 输入以下命令生成安装包程序
-
- C:\Users\欧阳磊\Desktop\startmenu>binarycreator.exe -c config/config.xml -p packages install.exe -v
- # 以下是生成安装包的过程
-
- [0] Parsed arguments, ok.
- [4]
- Collecting information about available packages...
- [8] Found subdirectory "org.qtproject.ifw.example"
- [10] - it provides the package "org.qtproject.ifw.example" - "1.0.0-1"
- [14] Copying component data for "org.qtproject.ifw.example"
- [19] Compressing data directory "audio"
- [38] Compressing data directory "bearer"
- [63] Compressing data directory "iconengines"
- [76] Compressing data directory "imageformats"
- [329] Compressing data directory "mediaservice"
- [435] Compressing data directory "platforms"
- [768] Compressing data directory "playlistformats"
- [823] Compressing data directory "sqldrivers"
- [1068] Compressing data directory "styles"
- [1112] Compressing data directory "translations"
- [1684] Compressing files found in data directory: ("D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/D3Dcompiler_47.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/libEGL.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/libgcc_s_dw2-1.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/libGLESV2.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/libstdc++-6.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/libwinpthread-1.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/music.db", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/music1.exe", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/opengl32sw.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Core.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Gui.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Multimedia.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Network.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Sql.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Svg.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/Qt5Widgets.dll", "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/packages/org.qtproject.ifw.example/data/README.txt")
- [12233] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1audio.7z.sha1"
- [12241] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1audio.7z"
- [12249] Generated sha1 hash: "ffeca0a73eadfe439bf181bc5aae46cd28f65e80"
- [12253] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1bearer.7z.sha1"
- [12259] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1bearer.7z"
- [12266] Generated sha1 hash: "575ba7628c5da58d117384d2efdf495ce507a318"
- [12270] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1iconengines.7z.sha1"
- [12276] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1iconengines.7z"
- [12284] Generated sha1 hash: "122694b718c342748771d100990eae8604a9d8e1"
- [12289] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1imageformats.7z.sha1"
- [12294] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1imageformats.7z"
- [12303] Generated sha1 hash: "1ac50a65a290dd9e6d6f878dab2b25af158808bb"
- [12309] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1mediaservice.7z.sha1"
- [12315] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1mediaservice.7z"
- [12323] Generated sha1 hash: "463cbb639b0283b86231ed36b88d86fa9579c6d2"
- [12327] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1platforms.7z.sha1"
- [12333] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1platforms.7z"
- [12342] Generated sha1 hash: "4f7e6857e3515e03f3c341116c58fed438052e0e"
- [12345] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1playlistformats.7z.sha1"
- [12352] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1playlistformats.7z"
- [12405] Generated sha1 hash: "5f4b28f321c56360ada544cf8d4eb287ce09d2d0"
- [12409] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1sqldrivers.7z.sha1"
- [12417] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1sqldrivers.7z"
- [12426] Generated sha1 hash: "b220571bbf43d05d0da17d93aa26aaa94415116b"
- [12430] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1styles.7z.sha1"
- [12437] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1styles.7z"
- [12445] Generated sha1 hash: "007e72259db84c7c455432ad8793b7db2ee978e0"
- [12449] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1translations.7z.sha1"
- [12456] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1translations.7z"
- [12465] Generated sha1 hash: "90b93b8a85db276cad171bf5d15b581274852964"
- [12470] Hash is stored in "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1content.7z.sha1"
- [12477] Creating hash of archive "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1content.7z"
- [12528] Generated sha1 hash: "53cefc29b3d6b2eec6eb87a5b6d3d1f0a06eea3d"
- [12533] Copy meta data for package "org.qtproject.ifw.example" using "packages/org.qtproject.ifw.example/meta/package.xml"
- [12540] calculate size of directory "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/data"
- [12573] Copying associated "script" file "packages/org.qtproject.ifw.example/meta/installscript.qs"
- [12581] done.
-
- [12583] Begin to copy configuration file and data.
- [12585] Copying associated "configuration" file "D:/QtInstallerFramework/QtIFW-3.0.4/examples/startmenu/config/config.xml"
- [12595] done.
-
- [12596] Read dom element: <Name>Start Menu Shortcut Example</Name>.
- [12599] Read dom element: <Version>1.0.0</Version>.
- [12603] Read dom element: <Title>Start Menu Shortcut Example</Title>.
- [12606] Read dom element: <Publisher>Qt-Project</Publisher>.
- [12609] Read dom element: <StartMenuDir>Qt Installer Framework Examples</StartMenuDir>.
- [12613] Read dom element: <TargetDir>@HomeDir@/IfwExamples/startmenu</TargetDir>.
- [12617] done.
-
- [12728] Creating the binary
- [12826] Creating resource archive for "org.qtproject.ifw.example"
- [12831] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1audio.7z" ("32.81 KiB")
- [12837] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1audio.7z.sha1" ("40.00 bytes")
- [12843] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1bearer.7z" ("23.60 KiB")
- [12849] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1bearer.7z.sha1" ("40.00 bytes")
- [12857] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1iconengines.7z" ("15.45 KiB")
- [12863] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1iconengines.7z.sha1" ("40.00 bytes")
- [12870] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1imageformats.7z" ("452.46 KiB")
- [12877] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1imageformats.7z.sha1" ("40.00 bytes")
- [12884] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1mediaservice.7z" ("138.68 KiB")
- [12891] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1mediaservice.7z.sha1" ("40.00 bytes")
- [12897] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1platforms.7z" ("651.78 KiB")
- [12905] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1platforms.7z.sha1" ("40.00 bytes")
- [12911] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1playlistformats.7z" ("10.77 KiB")
- [12918] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1playlistformats.7z.sha1" ("40.00 bytes")
- [12926] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1sqldrivers.7z" ("493.75 KiB")
- [12932] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1sqldrivers.7z.sha1" ("40.00 bytes")
- [12940] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1styles.7z" ("65.42 KiB")
- [12946] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1styles.7z.sha1" ("40.00 bytes")
- [12954] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1translations.7z" ("454.49 KiB")
- [12960] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1translations.7z.sha1" ("40.00 bytes")
- [12968] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1content.7z" ("16.83 MiB")
- [12978] Appending "C:/Users/欧阳磊/AppData/Local/Temp/binarycreator-l9Mfi9/org.qtproject.ifw.example/1.0.0-1content.7z.sha1" ("40.00 bytes")
- [13038] Cleaning up...
生成安装包程序之后,你就可以点击运行这个程序进行安装了,以下为安装示例
安装完以后,去安装目录下找到Music.exe点击运行,如果运行成功,则说明安装包是没问题的。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。