Results 1 to 2 of 2

Thread: Subclassing QThread — undefined reference to vtable

  1. #1
    Join Date
    Jun 2014
    Posts
    30
    Thanks
    4
    Qt products
    Qt5

    Default Re: Subclassing QThread — undefined reference to vtable

    I understand that the undefined reference to vtable error means that I have a pure virtual function that must be implemented. I cannot for the life of me find what I am missing to make this class compile.

    WaspThread.h

    Qt Code:
    1. #include <QThread>
    2.  
    3. class WaspThread : public QThread
    4. {
    5. Q_OBJECT
    6.  
    7. protected:
    8. void run();
    9. };
    To copy to clipboard, switch view to plain text mode 

    WaspThread.cpp

    Qt Code:
    1. #include "WaspThread.h"
    2.  
    3. void WaspThread::run()
    4. {
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    project.pro

    Qt Code:
    1. SOURCES += WaspThread.cpp
    2. HEADERS += WaspThread.h
    To copy to clipboard, switch view to plain text mode 

    I have the header and source files in my project file. I have tried cleaning out my build directory and re-running qmake multiple times.


    Added after 21 minutes:


    I just figured out the problem. I had forgotten to export the WaspThread class so that the executable utilizing the DLL could find WaspThread. It was a silly mistake. I made it because I forgot that in Windows land you need to export everything whereas in Linux you don't.
    Last edited by jmalicke; 14th August 2014 at 03:46.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Subclassing QThread — undefined reference to vtable

    If you want to detect that when working on Linux you can enable symbol hiding there as well

    Qt Code:
    1. QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden
    2. QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Undefined reference to vtable.
    By hakermania in forum Newbie
    Replies: 3
    Last Post: 10th September 2011, 18:10
  2. undefined reference to 'vtable ...'
    By GUIman in forum Newbie
    Replies: 5
    Last Post: 10th March 2011, 01:38
  3. Qt Undefined Reference to vtable
    By ctote in forum Qt Programming
    Replies: 18
    Last Post: 24th February 2010, 22:24
  4. Undefined reference to 'vtable for XXX'
    By Sheng in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 15:59
  5. undefined reference to vtable
    By renjithmamman in forum Qt Programming
    Replies: 5
    Last Post: 2nd July 2006, 04:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.