gpt4 book ai didi

c++ - windeployqt 不会为调试应用程序部署 qwindowsd.dll

转载 作者:行者123 更新时间:2023-12-04 17:31:02 27 4
gpt4 key购买 nike

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

This application failed to start because no Qt platform plugin could be initialized.



到目前为止,我已经尝试过:
  • 指定 --debugwindeployqt命令行。那失败了,因为 Qt5Coredd.dll找不到(注意双 d)。
  • 验证没有设置 Qt 插件相关的环境变量。
  • 已查 PATH确保它不包含任何带有 platforms 的文件夹目录。

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

    最佳答案

    这显然是 Qt 拖延修复的一个已知问题,但我在 CMake 中找到了一个解决方法 - 这适用于 Ninja 生成器/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()

    关于c++ - windeployqt 不会为调试应用程序部署 qwindowsd.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59828611/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com