首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >windeployqt不为调试应用程序部署qwindowsd.dll

windeployqt不为调试应用程序部署qwindowsd.dll
EN

Stack Overflow用户
提问于 2020-01-20 17:53:04
回答 1查看 527关注 0票数 4

我试图使用windeployqt.exe (QT5.13.2)为CMake 3.16生成的调试应用程序部署dll。除了平台插件dll之外,所有dll都被正确部署,后者部署qwindows.dll而不是qwindowsd.dll,并在尝试运行可执行文件时导致以下错误:

这个应用程序启动失败,因为没有Qt平台插件可以初始化。

到目前为止,我已经尝试过:

  • windeployqt命令行中指定--debug。这失败是因为找不到Qt5Coredd.dll (请注意没有设置与Qt插件相关的环境变量的双重Qt5Coredd.dll
  • 检查PATH以确保它不包含带有platforms目录的任何文件夹。

)

如果我手动复制qwindowsd.dll,一切都正常。不过,我真的很想弄清楚我对windeployqt做错了什么。

EN

回答 1

Stack Overflow用户

发布于 2021-08-31 22:26:48

这显然是Qt在修复过程中遇到的一个已知问题,但我在CMake中找到了一个解决办法--这既适用于忍者生成器/ Visual内置的CMake支持,也适用于常规的Visual解决方案生成器。

代码语言:javascript
复制
# 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()
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59828611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档