无法使用 Qt 运行“hello world”控制台应用程序

时间:2021-08-01 13:51:29

标签: c++ qt c++11 qt-creator

我正在使用 Qt Creator 5.12.11(64 位)构建程序。

我只想用 Qt 构建一个简单的“hello world”控制台应用程序,但在点击 RUN 按钮后它只是构建,但它没有运行程序所以我找到了“hello_world.exe”文件并尝试运行它,但我收到一条消息说

<块引用>

“由于未找到 Qt5Cored.dll,代码执行无法继续。 重新安装程序可能会解决此问题。”

所以我复制并粘贴了那个 DLL 文件,最后它起作用了

如何永远解决这类问题?

我使用 Windows 10 (✖64)

我已经在 C:\Qt 安装了 Qt5.12.11

这是我的配置文件和源文件

另外,我是 Qt 的新手。

QT -= gui

CONFIG += c++11 console
CONFIG -= app_bundle

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated `before Qt 6.0.0`

SOURCES += \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

和源文件

#include <QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    cout<<"Hello";

    return a.exec();
}

0 个答案:

没有答案