简体   繁体   English

Qt 6.1.0 MinGW 包含带有“__imp__ZN13QStateMachine…”的错误

[英]Qt 6.1.0 MinGW Include ERROR with “__imp__ZN13QStateMachine…”

Here I'm using Qt Creator and today when I tried to compile this code it happened to cause some errors.在这里,我使用的是 Qt Creator,今天当我尝试编译此代码时,它碰巧导致了一些错误。 code:代码:

#include "mainwindow.h"

#include <QApplication>
#include <QPushButton>
#include <QGraphicsItem>

#include <QtStateMachine/QState>
#include <QtStateMachine/QStateMachine>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QPushButton button("State Machine");
    QStateMachine machine;
    QState* s1 = new QState(&machine);
    QState* s2 = new QState(&machine);
    QState* s3 = new QState(&machine);
    s1->assignProperty(&button, "geometry", QRect(100, 100, 100, 50));
    s2->assignProperty(&button, "geometry", QRect(300, 100, 100, 50));
    s3->assignProperty(&button, "geometry", QRect(200, 200, 100, 50));

    s1->addTransition(&button, SIGNAL(clicked()), s2);
    s2->addTransition(&button, SIGNAL(clicked()), s3);
    s3->addTransition(&button, SIGNAL(clicked()), s1);

    machine.setInitialState(s1);
    machine.start();
    button.show();

    return a.exec();
}

And the errors are as followed错误如下

D:\Users\STRING10\Documents\QtProjects\build-QStateMachineTest-Desktop_Qt_6_1_0_MinGW_64_bit-Debug..\QStateMachineTest\main.cpp:15: error: undefined reference to \`__imp__ZN13QStateMachineC1EP7QObject' debug/main.o: In function \`qMain(int, char**)': D:\Users\STRING10\Documents\QtProjects\build-QStateMachineTest-Desktop_Qt_6_1_0_MinGW_64_bit-Debug/../QStateMachineTest/main.cpp:15: undefined reference to \`__imp__ZN13QStateMachineC1EP7QObject'

I have tried to find out if I missed the repository but it really exists in my computer and I have made the compiler as MinGW which do have a repository named QState.我试图找出我是否错过了存储库,但它确实存在于我的计算机中,并且我已将编译器设为 MinGW,它确实有一个名为 QState 的存储库。

Here's my.pro:这是我的.pro:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# 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 \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

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

In Qt6 QStateMachine (and the other similar classes) belong to the QtStateMachine submodule, no longer to the QtCore submodule, so add QT += statemachine to the.pro.在Qt6中QStateMachine(和其他类似的类)属于QtStateMachine子模块,不再属于QtCore子模块,所以在.pro中添加QT += statemachine statemachine。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM