前言
在 Windows 平台,通常使用 Qt 的工具 windeployqt
将可执行文件的相关 Qt 依赖项部署到当前路径下。
Windows windeployqt 部署工具
Windows 部署工具 windeployqt
旨在自动化创建一个可部署文件夹的过程,该文件夹包含运行应用程序所需的 Qt 相关依赖项(库、QML 导入、插件和翻译)。它为 Windows 桌面应用程序创建了一个安装树,可以轻松地捆绑到安装包中。
该工具可以在 QTDIR/bin/windeployqt
中找到。为了正确运行,它需要在构建环境中运行。当使用 Qt 在线安装器时,应使用脚本 QTDIR/bin/qtenv2.bat
来设置它。
对于 Windows 桌面应用程序,默认情况下,编译器所需的运行时文件也会复制到部署文件夹中(除非指定了 --no-compiler-runtime
选项)。在 Microsoft Visual C++使用的发布版本中,这些包括 Visual C++可再发行包,这些包旨在由应用程序的安装程序在目标机器上递归安装。否则,将使用编译器运行时的共享库。
windeployqt
工具帮助说明:
Usage: windeployqt [options] [files]
Qt Deploy Tool 6.0.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, 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 help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
--dir <directory> Use directory instead of binary directory.
--qmake <path> Use specified qmake instead of qmake from PATH.
--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 Qt6Core library.
--ignore-library-errors Ignore errors when libraries cannot be fo