【QtQuick3D学习】使用Qt for Windows - Deployment工具windeployqt打包Qt程序——基于C++和Cmake

使用Qt for Windows - Deployment工具windeployqt打包Qt程序——基于C++和Cmake

我们编写一个应用程序的最终目的就是打包并发布给其他人使用

所以这里开始学习打包发布基于Qt编写的应用程序

实验环境如下

itemversion
Qt6.6.0
Qt Creator11.0.3 (Community)
Qt Design Studio4.1.0
KitMinGW 11.2.0 (64-bit)

根据网上经验,Qt官方提供了相关工具Qt for Windows - Deployment | Qt 6.6

在Qt安装目录的对应文件夹下

在这里插入图片描述

步骤

构建Release

首先将构建切换至Release

然后构建运行,确保能正确运行

手动打包

找到构建Release的文件夹,并拷贝生成的xxx.exe文件

文件夹和文件可以从项目窗口中找到

在这里插入图片描述

在这里插入图片描述

此时直接双击运行软件,将会提示缺少各种xxx.dll

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

手动拷贝各种缺少的xxx.dll后,还会有错误

在这里插入图片描述

在这里插入图片描述

所以手动打包过于麻烦,决定使用工具自动打包

自动打包

默认没有添加环境变量,所以直接执行windeployqt无法识别,解决方法是将上面展示windeployqt的bin文件夹添加到环境变量

然后执行指令

windeployqt .\cWithDesign.exe

文件夹内将会多出很多文件,此时双击执行应用程序,就能执行了

在这里插入图片描述

如果要求不高,此时已经可以压缩发送给别人使用了

ps:根据提示,如果使用了Qt Quick,还需要将qml路径增加到指令中

Usage: C:\Qt\6.6.0\mingw_64\bin\windeployqt.exe [options] [files]
Qt Deploy Tool 6.6.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 your application uses Qt Quick, run:
  windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>

Options:
  -?, -h, --help                      Displays help on commandline options.
  --help-all                          Displays help, including generic Qt
                                      options.
  • 25
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值