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

问题描述 投票:0回答:2

最近我需要为我的 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 开发人员是否计划对此做些什么?

c++ qt deployment qml qtquick2
2个回答
23
投票

对于 windeployqt,有选项

--qmldir

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

所以它也检查导入并获取 qml dll。

所有这些都在链接文章中进行了描述


0
投票

@Vova Shevchyk @RvdK 的回答是正确的,应该可以。 https://stackoverflow.com/a/39717117/15701702

" --qmldir f:\myApp\sources ",这里你应该输入的路径是你正在开发应用程序的路径,即来自 QtCreator 的项目路径。并且 app.exe 应该来自发布版本。您可以将该 app.exe 放在您想要的任何目录中并指定路径。部署将在该目录中添加所有必要的文件和 dll。

© www.soinside.com 2019 - 2024. All rights reserved.