Qt 可执行错误 - dll 库

Qt executable error- dll library

本文关键字:dll 错误 可执行 Qt      更新时间:2023-10-16

一个Qt应用程序在从QtCreator执行时完美运行,当我尝试从调试文件夹(没有QtCreator)执行它时不会运行。它要求很多.dll文件,我一个接一个地下载它们,并添加到调试文件夹中。现在我得到了错误:

The program can't start because libwinpthread-1.dll is missing from your computer.
Try reinstalling the program to fix this problem.

我在互联网上的任何地方都找不到libwinpthread-1.dll。我做错了什么?

可执行文件的路径为:

C:QtToolsQtCreatorbinbuild-SimpleText1_3-Desktop_Qt_5_2_1_MinGW_32bitDebug

项目文件:

#-------------------------------------------------
#
# Project created by QtCreator 2014-04-04T14:29:48
#
#-------------------------------------------------
QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = SimpleText1_3
TEMPLATE = app

SOURCES += main.cpp
        mainwindow.cpp
HEADERS  += mainwindow.h
FORMS    += mainwindow.ui
CONFIG += console c++11
QMAKE_CXXFLAGS += -std=c++11

和主要.cpp:

#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}

当您在Qt Creator中运行应用程序时,一切都很好,但是当您从调试文件夹中运行.exe文件时,会出现dll丢失错误。是真的!首先将Qt Creator设置为发布模式。您必须将这些dll和文件夹复制到"释放"文件夹:

platforms --> Folder
icudt52.dll
icuin52.dll
icuuc52.dll
msvcp110.dll
msvcr110.dll
Qt5Core.dll
Qt5Gui.dll
Qt5Widgets.dll

上面的dll是Visual Studio编译器和唯一的Core和GUI库。

祝你好运。亚阿里。

转到以下Qt文档链接:https://wiki.qt.io/Deploy_an_Application_on_Windows。请严格按照说明进行操作。 我不必做粗暴的方法。 我确实收到了缺少环境变量的警告,但围栏确实有效。请注意发布版本与调试版本。