Windeployqt 找不到所有的依赖项

Windeployqt does not find all the dependencies

本文关键字:依赖 找不到 Windeployqt      更新时间:2023-10-16

我在发布模式下构建了我的Qt项目,并拥有.exe文件。我正在使用Qt 5.7 32-bit for Desktop (MSVC 2015) cmd并运行C:Qt5.7msvc2015binwindeployqt.exe my_app.exe

但是,在运行它时,windeployqt找不到所有依赖项。我得到这个输出。

Adding Qt5Svg for qsvgicon.dll
Direct dependencies: Qt5Core Qt5Gui Qt5Widgets
All dependencies   : Qt5Core Qt5Gui Qt5Widgets
To be deployed     : Qt5Core Qt5Gui Qt5Svg Qt5Widgets

当我尝试运行.exe文件时,我仍然缺少Qt5Network.dllQt5xml.dllQt5XmlPatterns.dllQt5WebEngineWidgets.dllQt5WebEngineCore.dllQt5Quick.dll。它也缺少libeay32.dllssleay32.dll.

在我的 .pro 文件中,我有QT += core gui xml xmlpatterns widgets webenginewidgets network

我一直在寻找解决方案,即使我可以手动复制粘贴它们并且它可以工作或使用 -network -xml 等添加它们,我想看看是否有办法将所有依赖项添加在一起。

前言

我认为windeployqt现在不会尝试部署libeay32.dllssleay32.dll,因为它们不在c:Qt5.8mingw53_32bin(但是,它们在c:QtToolsmingw530_32optbin

如果windeployqt工作无错误,那么windeployqt ./部署所有Qt DLL,没有任何参数。

不幸的是,windeployqt仍然是错误的,因为有时它不会创建必需的并且创建无用的。

因此,您可以添加必需的(例如。 --core ) 并跳过创建无用(例如。 --no-svg ):

windeployqt --compiler-runtime --core --gui --network --widgets --winextras --no-svg --no-system-d3d-compiler --no-translations --no-opengl-sw --no-angle ./

更多package_name和命令 — https://doc.qt.io/qt-5/windows-deployment.html。

您可以创建变量 QT 的 qmake-parser,在包名前面附加--并插入到 windeployqt-command:

DESTDIR = "path/to/dest"
QT     = core gui network widgets winextras
CONFIG( release, debug|release ) {
    PACKAGES = ""
    for(package,QT){
        PACKAGES += "--$${package} "
    }
    NO_PACKAGES = --no-svg 
        --no-system-d3d-compiler --no-translations --no-opengl-sw --no-angle
    RETURN = $$escape_expand(nt)
    # windeployqt
    QMAKE_POST_LINK += $$RETURN windeployqt --compiler-runtime 
        $${PACKAGES} $${NO_PACKAGES} 
        $$quote($$shell_path($$DESTDIR))
    # copy OpenSSL dlls
    OPENSSLFILES = $$shell_path($$PWD/../../bin_openssl_1.0.2h/*.dll)
    DDIR = $$shell_path($$DESTDIR)
    QMAKE_POST_LINK += $$RETURN $$QMAKE_COPY $$quote($$OPENSSLFILES) $$quote($$DDIR)
}