Qt 应用程序无法在发布版本中运行

发布于 2025-01-13 16:38:10 字数 417 浏览 1 评论 0原文

我正在使用 Visual Studio 2017 和 qt 5.12.9 msvc2017_64。

当我在“Debug x64”中编译该程序时,该应用程序运行良好。当我在“Release x64”中编译程序时,程序可以成功编译,没有任何错误,但是应用程序无法打开并且没有显示任何内容(没有警告等)。我使用了windeployqt。

然后,我尝试在“Release x64”中调试程序,Visual Studio 向我展示了下图中的内容。

输入图片这里的描述

我应该怎么做才能让程序在release中运行?感谢您的帮助。

I am using visual studio 2017 and qt 5.12.9 msvc2017_64.

When I compiled the program in "Debug x64", the application worked fine. When I compiled the program in "Release x64", the program can be compiled successfully without any error, but the application cannot be opened and showed nothing (no warning, etc.). I used the windeployqt.

Then, I tried to debug the program in "Release x64" and the visual studio showed me something in the following image.

enter image description here

What should I do to make the program run in release? Thanks for help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜访吸血鬼 2025-01-20 16:38:10

这是因为windeployqt不会复制所有需要的dll来释放目录。
缺少一些 dll,您需要手动复制。
有两种方法可以找到它。

  1. 使用依赖步行器。识别丢失的库并将其复制到您的发布目录。
  2. 将以下文件夹从 C:\Qt\Qt5.12\5.12.9\msvc2017_64 复制到您的 exe 所在的文件夹
plugins
qml
translations
mkspecs

从 C:\Qt\Qt5.12\5.12 复制所有 dll。 9\msvc2017_64\bin 文件夹到 exe 的根文件夹。

还创建 qt.conf 文件及其所有以下行

[Paths] 
Prefix=. 
Libraries=lib 
Plugins=plugins 
Qml2Imports=qml 
Translations=translations 
Headers=include 
Documentation=doc 

现在运行您的 exe。程序运行后。尝试删除一些dll。如果程序使用任何dll,则不会被删除。通过这样做,未使用的 dll 将被删除。类似的尝试使用 qml 文件夹和插件文件夹。

This is because windeployqt will not copy all required dll to release the directory.
There is some missing dlls that you need to copy manualy.
There is two way to find it out.

  1. Use a dependency walker. identify the missing library and copy it to your release directory.
  2. Copy the following folder from C:\Qt\Qt5.12\5.12.9\msvc2017_64 to the folder where, your exe is located
plugins
qml
translations
mkspecs

Copy all dll from C:\Qt\Qt5.12\5.12.9\msvc2017_64\bin folder to root folder of your exe.

also create qt.conf filed and all following lines to it

[Paths] 
Prefix=. 
Libraries=lib 
Plugins=plugins 
Qml2Imports=qml 
Translations=translations 
Headers=include 
Documentation=doc 

Now run your exe. after the program runs. try to delete some dll. if the program is using any dll, it will not get deleted. by doing this unused dll will be removed. similar try with qml folder and plugin folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文