Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Yes, I am getting "undefined reference to `vtable for Window'"

Yes, I am getting "undefined reference to `vtable for Window'"

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vincegata
    wrote on last edited by
    #1

    Hello,

    So, I am getting the error when I do the build:
    $ clang++ -g -std=c++14 subc*.cpp -I/usr/include/qt4 -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtCore -lQtCore -lQtGui

    $ tmp/subcl-f65a46.o: In function Window': undefined reference to vtable for Window'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I am on Linux, I am not using Qt Creator, I am not using qmake. That is because this GUI qt project will be added to a (very) large project with its own build system based on make files.

    This is the example straight out of the Qt For Beginners page.

    // subcl.h
    #ifndef SUBCL_H
    #define SUBCL_H
    #include <QWidget>
    class Window : public QWidget
    {
     Q_OBJECT
     public:
      explicit Window(QWidget *parent = 0);
      virtual ~Window();
     signals:
     public slots:
    };
    #endif 
    
    // subcl.cpp
    #include "subcl.h"
    Window::Window(QWidget *parent) : QWidget(parent) {}
    Window::~Window(void) {}
    
    // subclmain.cpp
    #include <QApplication>
    #include "subcl.h"
    int main(int argc, char **argv)
    {
     QApplication app (argc, argv);
     Window window;
     window.show();
     return app.exec();
    }
    

    I've done the googling.

    Can someone help me with this -- thank you!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vincegata
      wrote on last edited by
      #2

      Note, I added the virtual desctructor (did not help.)

      1 Reply Last reply
      0
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        After adding the Q_OBJECT macro you must run the header through moc, compile the generated source, and include it in the link stage.

        Normally qmake would do that for you.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved