Saturday, 10 December 2016

c++ - undefined reference to `vtable for MyCalss'

I've created new project with QTCreator using Empty Qt Project



MocTest.pro



QT += core
QT -= gui

TARGET = MocTest

CONFIG += console

TEMPLATE = app


SOURCES += \
main.cpp


main.cpp




#include 
#include

class A : public QObject
{
Q_OBJECT

public:
A() {}


public slots:
void slotA() {std::cout<<"Hi!";}
};

class B : public QObject
{
Q_OBJECT

public:

B () {}

void doB() {emit ss();}

signals:
void ss();
};

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

QCoreApplication app (argc, argv);
A a;
B b;
return app.exec();
}


I got errors



D:\Test\MocTest\debug\main.o:-1: In function `ZN1AC1Ev':




D:\Test\MocTest\main.cpp:9: error: undefined reference to `vtable for A'



D:\Test\MocTest\main.cpp:20: error: undefined reference to `vtable for B'



D:\Test\MocTest\main.cpp:4: error: undefined reference to `vtable for A'



D:\Test\MocTest\main.cpp:15: error: undefined reference to `vtable for B'



collect2.exe:-1: error: error: ld returned 1 exit status

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...