使用Qt Installer Framework制作安装包

2018年07月01日 03:45:37 大黄老鼠 阅读数:878 标签: qt更多

个人分类: Qt
 
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32768743/article/details/80871697

步骤

制作安装包的步骤:

  • 去官网下载Qt Installer Framework的安装包并安装(已经安装的请跳过这步)
  • 使用windeployqt.exe集齐所需依赖
  • 使用binarycreator.exe创建安装包

具体操作流程:

安装Qt Installer Framework

下载地址:http://download.qt.io/official_releases/qt-installer-framework/




搜集依赖

  • 使用Release模式构建项目

  • 在release目录下删掉不必要的文件
  • 运行windeployqt.exe命令
[windeployqt.exe路径] --release --qml --qmldir [qml源码路径] [exe文件路径]
  • 1

如在我的环境下是

D:\Qt\Qt5.11.0\5.11.0\mingw53_32\bin\windeployqt.exe --release --qml --qmldir D:\src\qml\huorong\ huorong.exe
  • 1
  • 手动拷贝其他的dll

我使用的是mingw53_32,需要拷贝以下文件

libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll

创建安装包

  • 将上面搜集的依赖拷贝到installer\packages\cn.net.pikachu.huorong\data文件夹下
  • 运行binarycreator.exe命令
[binarycreator.exe路径] -c [config.xml路径] -p [packages路径] [生成的安装程序exe文件名] -v
  • 1

如在我的环境下是

D:\Qt\QtIFW-3.0.4\bin\binarycreator.exe -c installer/config/config.xml -p installer/packages huorong_install.exe -v
  • 1

最后的演示效果

思考与总结

如果Qt提供一键生成安装包就好了,何必这么麻烦呢?应该可以把这些操作用脚本写好,然后集成到QtCreator中。

附:

配置文件

config.xml

<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>火绒安全软件</Name>
<Version>0.1.0</Version>
<Title>火绒安全软件</Title>
<Publisher>大黄老鼠</Publisher>
<!-- Directory name is used in component.xml -->
<StartMenuDir>pikachu</StartMenuDir>
<TargetDir>@HomeDir@/pikachu/huorong</TargetDir>
</Installer>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

package.xml

<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>火绒安全软件</DisplayName>
<Description>可执行文件</Description>
<Version>0.1.0-1</Version>
<ReleaseDate>2018-07-01</ReleaseDate>
<Default>true</Default>
<Script>installscript.qs</Script>
<ForcedInstallation>true</ForcedInstallation>
</Package>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

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@/huorong.exe", "@StartMenuDir@/火绒安全软件.lnk",
"workingDirectory=@TargetDir@", "iconPath=%SystemRoot%/system32/SHELL32.dll",
"iconId=2", "description=Open README file");
component.addOperation("CreateShortcut", "@TargetDir@/huorong.exe", "@HomeDir@/Desktop/火绒安全软件.lnk"); component.addOperation("CreateShortcut", "@TargetDir@/maintenancetool.exe", "@StartMenuDir@/更新或卸载 火绒安全软件.lnk");
}

最新文章

  1. css的relative和position探究
  2. Effective Java 68 Prefer executors and tasks to threads
  3. nginx 日志分析
  4. Windows 7 64位下使用ADB驱动
  5. 设置UIButton文字大小颜色不同
  6. Android原型界面设计工具
  7. “幸福企业”定义-参观“MES项目”有感
  8. CCF2013123最大的矩形(C语言版)
  9. rpm包相关操作
  10. 【Zookeeper】角色、顺序号、读写机制
  11. C#连接和操作Oracle数据
  12. 【Linux】Mac PD set centos static ip
  13. cmd命令行模式开启或关闭 windows功能 (转载)
  14. Js 中一系列宽度和高度的学习
  15. 38)django-组合搜索
  16. platform_device module
  17. JobScheduler android任务调度处理组件(类似QuartZ)
  18. JS四舍五入保留两位小数
  19. hog+svm+检测人(代替默认的参数)
  20. db2表空间及日志文件调整

热门文章

  1. OpenCV + python 实现人脸检测(基于照片和视频进行检测)
  2. NaviSoft31.源码开发完成
  3. Failed to execute &#39;write&#39; on &#39;Document&#39;动态载入的js不能执行write
  4. 框架源码系列七:Spring源码学习之BeanDefinition源码学习(BeanDefinition、Annotation 方式配置的BeanDefinition的解析)
  5. 【CentOS-7+ Ambari 2.7.0 + HDP 3.0+HAWQ2.3.00】遭遇问题及解决记录
  6. 寄存器理解 及 X86汇编入门
  7. Android 官方独立 adb / fastboot 工具包
  8. rmq区间最值
  9. Assignments---(贪心)
  10. mui 轮播