将 Qt5Core.dll 和插件从 mingw32 文件夹复制到 exe 文件所在的本地目录时出现段错误

问题描述 投票:0回答:1

Windows 10, mingw32 (C:\msys64\mingw32 in), qtcreator(pacman安装)。 我的程序 (HelloAnim.exe) 是 qt quick GUI,我构建了一个发布版本,它适用于构建文件夹:

 "D:\qt\build-HelloAnim-Desktop_Qt_5_15_5_shared_MinGW_w64_MINGW32_MSYS2-Release\release"

然而,当我将 Qt5Core.dll 从 mingw32 文件夹复制到 exe 文件夹,并运行 HelloAnim.exe 时,错误弹出如下:

This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

然后我从C:\msys64\mingw32\share\qt5复制文件夹“plugins”到exe文件夹下运行,还是一样的错误

然后我编辑一个 qt.conf 文件,放在 exe 文件夹中,内容如下:

[Paths]
Plugins=D:/qt/build-HelloAnim-Desktop_Qt_5_15_5_shared_MinGW_w64_MINGW32_MSYS2-Release/release/plugins

然后运行HelloAnim.exe,出现segmentation fault错误如下:

# ./HelloAnim.exe
Debug: arguments=======  ("D:\\qt\\build-HelloAnim-Desktop_Qt_5_15_5_shared_MinGW_w64_MINGW32_MSYS2-Release\\release\\HelloAnim.exe")
Debug: current dir:  "D:/qt/build-HelloAnim-Desktop_Qt_5_15_5_shared_MinGW_w64_MINGW32_MSYS2-Release/release"
Warning: Attribute Qt::AA_UseOpenGLES must be set before QCoreApplication is created.
Debug: touch devices:  ()
Warning: QQmlApplicationEngine failed to load component
Warning: qrc:/main.qml:4:1: module "QtQuick.Layouts" is not installed
Warning: qrc:/main.qml:3:1: module "QtQuick.Controls" is not installed
Warning: qrc:/main.qml:2:1: module "QtQuick.Dialogs" is not installed
Warning: qrc:/main.qml:4:1: module "QtQuick.Layouts" is not installed
Warning: qrc:/main.qml:3:1: module "QtQuick.Controls" is not installed
Warning: qrc:/main.qml:2:1: module "QtQuick.Dialogs" is not installed
Warning: qrc:/main.qml:4:1: module "QtQuick.Layouts" is not installed
Warning: qrc:/main.qml:3:1: module "QtQuick.Controls" is not installed
Warning: qrc:/main.qml:2:1: module "QtQuick.Dialogs" is not installed
Segmentation fault

不知道为什么?

windows-10 qt5 mingw32
1个回答
0
投票

您的问题缺少很多细节,因此很难猜测您部署了什么以及缺少什么。 但是您的安装文件夹应该包含您的 exe 和 Qt5Core.dll、Qt5Network.dll、Qt5Widgets.dll(无论您的应用程序需要什么)。然后应该还有编译器自带的文件(libwinpthread-1.dll、libEGL.dll、libgcc_s_seh-1.dll、libGLESv2.dll)。再次取决于您的应用程序:opengl32sw.dll.

然后应该有几个文件夹: 音频载体图标引擎图像格式媒体服务

最重要的:平台

内部平台:qwindows.dll

但是与其手动维护所有这些,不如让 Qt 来完成这项工作更容易。有一个名为 windeployqt.exe 的工具(在 Qt 的 mingw/bin 文件夹中),这将为您完成这项工作。大多数时候,它不会遗漏任何文件。

© www.soinside.com 2019 - 2024. All rights reserved.