本文介绍了windeployqt不会为调试应用程序部署qwindowsd.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用windeployqt.exe(Qt 5.13.2)为CMake3.16生成的调试应用程序部署dll。除平台插件DLL外,所有DLL都部署正确,它部署的是qwindows.dll而不是qwindowsd.dll,并在我尝试运行可执行文件时导致以下错误:

到目前为止,我已尝试:

  • windeployqt命令行上指定--debug。该操作失败,因为找不到Qt5Coredd.dll(请注意双%d)。
  • 正在验证是否未设置与Qt插件相关的环境变量。
  • 已检查PATH以确保它不包含具有platforms目录的任何文件夹。
如果手动复制qwindowsd.dll,则一切正常。但是,我真的想找出我在windeployqt中做错了什么。

推荐答案

这显然是Qt迟迟未解决的一个已知问题,但我在CMake中想出了一个解决办法-它既适用于忍者生成器/Visual Studio的内置Cmake支持,也适用于常规的Visual Studio解决方案生成器

# Split windeployqt into 2 parts to fix issue with deploying debug plugins
add_custom_command(TARGET MyApp POST_BUILD
    COMMAND ${QT_PATH}/bin/windeployqt --compiler-runtime --no-plugins ${MY_APP_EXE})
if (CMAKE_GENERATOR STREQUAL "Ninja")
    # Ninja is a single-config generator so we can use CMAKE_BUILD_TYPE to generate different commands
    if (CMAKE_BUILD_TYPE STREQUAL "Debug")
        add_custom_command(TARGET MyApp POST_BUILD
            COMMAND ${QT_PATH}/bin/windeployqt --debug --no-compiler-runtime --no-translations --no-libraries ${MY_APP_EXE})
    else()
        add_custom_command(TARGET MyApp POST_BUILD
            COMMAND ${QT_PATH}/bin/windeployqt --release --no-compiler-runtime --no-translations --no-libraries ${MY_APP_EXE})
    endif()
else()
    # if in MSVC we have to check the configuration at runtime instead of generating different commands
    add_custom_command(TARGET MyApp POST_BUILD
        COMMAND cmd.exe /c if "$(Configuration)" == "Debug" ${QT_PATH}/bin/windeployqt --debug --no-compiler-runtime --no-translations --no-libraries ${MY_APP_EXE})
    add_custom_command(TARGET MyApp POST_BUILD
        COMMAND cmd.exe /c if not "$(Configuration)" == "Debug" ${QT_PATH}/bin/windeployqt --release --no-compiler-runtime --no-translations --no-libraries ${MY_APP_EXE})
endif()

这篇关于windeployqt不会为调试应用程序部署qwindowsd.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 09:16