Qt5 程序发布:windeployqt使用

官方程序发布指导

  • windeployqt 使用: Usage: windeployqt [options] [files]
    options:可选打包参数
    files:打包的程序名称
  • options详情
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.
  --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 Qt5Core library.
  --no-plugins              Skip plugin deployment.
  --no-libraries            Skip library deployment.
  --qmldir <directory>      Scan for QML-imports starting from directory.
  --qmlimport <directory>   Add the given path to the QML module search
                            locations.
  --no-quick-import         Skip deployment of Qt Quick imports.
  --no-translations         Skip deployment of translations.
  --no-system-d3d-compiler  Skip deployment of the system D3D compiler.
  --compiler-runtime        Deploy compiler runtime (Desktop only).
  --no-virtualkeyboard      Disable deployment of the Virtual Keyboard.
  --no-compiler-runtime     Do not deploy compiler runtime (Desktop only).
  --webkit2                 Deployment of WebKit2 (web process).
  --no-webkit2              Skip deployment of WebKit2.
  --json                    Print to stdout in JSON format.
  --angle                   Force deployment of ANGLE.
  --no-angle                Disable deployment of ANGLE.
  --no-opengl-sw            Do not deploy the software rasterizer library.
  --list <option>           Print only the names of the files copied.
                            Available options:
                             source:   absolute path of the source files
                             target:   absolute path of the target files
                             relative: paths of the target files, relative
                                       to the target directory
                             mapping:  outputs the source and the relative
                                       target, suitable for use within an
                                       Appx mapping file
  --verbose <level>         Verbose level (0-2).

Qt libraries can be added by passing their name (-xml) or removed by passing
the name prepended by --no- (--no-xml). Available libraries:
bluetooth concurrent core declarative designer designercomponents enginio
gamepad gui qthelp multimedia multimediawidgets multimediaquick network nfc
opengl positioning printsupport qml qmltooling quick quickparticles quickwidgets
script scripttools sensors serialport sql svg test webkit webkitwidgets
websockets widgets winextras xml xmlpatterns webenginecore webengine
webenginewidgets 3dcore 3drenderer 3dquick 3dquickrenderer 3dinput 3danimation
3dextras geoservices webchannel texttospeech serialbus webview
  • QtQuick程序简单打包
    直接用qt的命令行工具(最好与所用的编译工具对应)可以省去环境变量配置工作
 cd “需要打包的程序目录”
 windeployqt  --qmldir "qt安装路径"/“编译工具文件夹”/qml "打包的程序名称"
  • 有坑:打包时应该是只会检查启动时加载的库, 而一些 程序运行过程中才动态加载的库文件没有被打包.
    遇到的错误: module “QtCharts” is not installed. 因为QCharts库是在绘制图表时才动态加载, windeployqt 没有复制QCharts模块的依赖文件到打包路径, 如果用了QCharts模块的内容还需要将Qt5Charts.dll库文件和qml/QtCharts文件夹拷贝到发布路径下.
  • 一些依赖查看工具
    (这些工具都也只能检测到程序启动时调用的库文件)
  1. Dependencies: 下载地址
  2. Dependency Walker: 下载地址(win10下不太好用)
  3. dumpbin(VS自带工具)

版权声明:本文为anyinxi原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。