在Windows上部署QML应用程序的正确方法

时间:2016-02-04 08:10:59

标签: c++ qt deployment qml qtquick2

最近我需要为我的Qt-QML应用程序创建一个部署包。此过程非常繁琐,因为您需要手动查找和复制依赖项。如(官方?)Qt Wiki

所述
Copy the following into C:\Deployment\

 - The release version of MyApp.exe
 - All the .dll files from C:\Qt\5.2.1\mingw48_32\bin\
 - All the folders from C:\Qt\5.2.1\mingw48_32\plugins\ (If you used QML)
 - All the folders from C:\Qt\5.2.1\mingw48_32\qml\

Do the deletion steps below in C:\Deployment\ and all of its subdirectories.
After each deletion, launch C:\Deployment\MyApp.exe and test it.
If it stops working, restore the files you just deleted.

 - Launch MyApp.exe. While it is running, try to delete all DLLs.
   The DLLs that aren't used will go to the recycle bin,
   leaving behind only the DLLs that you need.
   (This trick doesn't work for .qml and qmldir files, however).
 - (If you used QML) Delete a few .qml files and try relaunching MyApp.exe.
   Repeat until you try all .qml files.
 - (If you used QML) Delete qmldir files from the folders that have no more DLLs or .qml files

对于任何现代工具,这样的程序看起来完全荒谬。是的,我知道windeployqt.exe,但它找不到所有.dll依赖项,对.qml个依赖项没有任何帮助。

有没有人意识到这个问题有更实用的方法,人们如何在大项目中处理这个问题?有没有可以提供帮助的工具?

Qt开发人员是否计划对此采取行动?

1 个答案:

答案 0 :(得分:5)

对于windeployqt,有选项--qmldir

windeployqt --qmldir f:\myApp\sources f:\build-myApp\myApp.exe

因此它也会检查导入并获取qml dll。

所有这些都在linked article

中描述