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

    @#include <QThread>

    class WaspThread : public QThread
    {
    Q_OBJECT

    protected:
    void run();
    };@

    WaspThread.cpp

    @#include "WaspThread.h"

    void WaspThread::run()
    {

    }@

    project.pro

    @SOURCES += WaspThread.cpp
    HEADERS += WaspThread.h@

    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.



  • 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.


  • Lifetime Qt Champion

    Hi,

    Got also hit by that one, did you saw that Qt provides macros to help you export the class cross-platform style ?

    On a side note, since you have it working, can you also update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.