Skip to content

Latest commit

 

History

History
155 lines (87 loc) · 4 KB

File metadata and controls

155 lines (87 loc) · 4 KB

 

 

 

 

 

 

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 Qt: version 4.7.0 (32 bit)
  • STL STL: GNU ISO C++ Library, version 4.4.5

 

 

 

 

 

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.