【问题标题】:windeployqt doesn't deploy qwindowsd.dll for a debug applicationwindeployqt 不会为调试应用程序部署 qwindowsd.dll
【发布时间】:2020-01-20 17:53:04
【问题描述】:

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

此应用程序无法启动,因为无法初始化 Qt 平台插件。

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

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

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

【问题讨论】:

  • 如果你添加详细标志,你会得到任何额外的信息吗?
  • @deW1 启用了级别 2 我可以看到它正在寻找发布和调试库的组合,但不知道为什么
  • 当你创建一个新的默认小部件应用程序 -> 选择 CMake -> 构建 -> 运行 windeployqt TestWidgets.exe 时它是否工作(例如)。我有 5.13.1 在那里工作正常。
  • 我也注意到了这样的问题,所有部署的插件都处于发布模式。我认为并不真正支持部署调试版本(我认为用例有限,因为分发 MSVC 调试运行时 IIRC 存在法律限制)。我认为值得创建一个最小的示例和错误报告。

标签: c++ qt qt5


【解决方案1】:

这显然是 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()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-17
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多