PDA

View Full Version : Subclassing QThread — undefined reference to vtable



jmalicke
14th August 2014, 04:46
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.

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.

anda_skoa
14th August 2014, 12:13
If you want to detect that when working on Linux you can enable symbol hiding there as well



QMAKE_CFLAGS_HIDESYMS += -fvisibility=hidden
QMAKE_CXXFLAGS_HIDESYMS += $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden


Cheers,
_