windeployqt doesn#39;t deploy qwindowsd.dll for a debug application(windeployqt不会为调试应用程序部署qwindowsd.dll)
本文介绍了windeployqt不会为调试应用程序部署qwindowsd.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用windeployqt.exe(Qt 5.13.2)为CMake3.16生成的调试应用程序部署dll。除平台插件DLL外,所有DLL都部署正确,它部署的是qwindows.dll而不是qwindowsd.dll,并在我尝试运行可执行文件时导致以下错误:
此应用程序无法启动,因为无法初始化任何Qt平台插件。
到目前为止,我已尝试:
- 在
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:windeployqt不会为调试应用程序部署qwindowsd.dll
基础教程推荐
猜你喜欢
- 常量变量在标题中不起作用 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
