Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) undefined reference to 'vtable for MyDialog'

 

link error.

 

 

 

 

 

 

Full error message

 

/MyFolder/main.o:: In function 'MyDialog':
/MyFolder/main.cpp:4: error: undefined reference to 'vtable for MyDialog'
/MyFolder/main.o:: In function '~MyDialog':
/MyFolder/main.cpp:4: error: undefined reference to 'vtable for MyDialog'
collect2: ld returned 1 exit status

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppLinkErrorUndefinedReferenceToVtableForMyDialog.pro

 

#-------------------------------------------------
#
# Project created by QtCreator 2010-12-29T14:26:41
#
#-------------------------------------------------
QT       += core
QT       -= gui
TARGET = CppLinkErrorUndefinedReferenceToVtableForMyDialog
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

 

 

 

 

 

main.cpp

 

#include <QObject>

class MyDialog : public QObject
{
  Q_OBJECT

  public slots:
    void onSomething() { }
};

int main()
{
  MyDialog dialog;
}

 

 

 

 

 

Solution

 

Seperate the MyDialog class in a header (.h) file and an implementation (.cpp) file.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict