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. Subclassing QThread — undefined reference to vtable
Forum Updated to NodeBB v4.3 + New Features

Subclassing QThread — undefined reference to vtable

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.3k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jmalicke
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jmalicke
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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 :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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