title: Undefined reference to already defined interface destructor
body: <p>I have an interface <code>QInterruptable</code> as follows:</p>
  
  <pre><code>#ifndef QINTERRUPTABLE_H
  #define QINTERRUPTABLE_H
  
  class QInterruptable {
  public:
      virtual void pause();
      virtual void resume();
      virtual void interrupt();
      virtual ~QInterruptable(){
  
      }
  };
  
  #endif // QINTERRUPTABLE_H
  </code></pre>
  
  <p>An example use of <code>QInterruptable</code> is in sub-classing a <code>QThread</code> WorkerObject for <a href="https://wiki.qt.io/QThreads_general_usage" rel="nofollow noreferrer">additional functionality</a>. </p>
  
  <p><code>QInterruptable</code> is used in my <code>ThreadWorker</code> header file</p>
  
  <pre><code>#ifndef THREADWORKER_H
  #define THREADWORKER_H
  
  #include &lt;QObject&gt;
  #include &lt;functional&gt;
  #include &lt;QWaitCondition&gt;
  #include &lt;QMutex&gt;
  
  #include "QInterruptable.h"
  
  class ThreadWorker : public QObject, public QInterruptable
  {
      Q_OBJECT
  
  private:
      QMutex mutex;
      QWaitCondition *waitCondition;
      std::function&lt;void ()&gt; runnable;
      bool shouldPause = false;
  
  public:
      explicit ThreadWorker(QObject *parent = nullptr);
      ThreadWorker(std::function&lt;void ()&gt; func);
      ~ThreadWorker();
  
      void setRunnable(const std::function&lt;void ()&gt; &amp;value);
  
  signals:
      void started();
      void progress(int value);
      void finished();
      void error();
  
  public slots:
      virtual void run();
      virtual void cleanup();
  
      // QInterruptable interface
  public:
      void pause()
      {
          shouldPause = true;
      }
      void resume()
      {
          shouldPause = false;
      }
      void interrupt()
      {
  
      }
  
      QMutex&amp; getMutex();
      QWaitCondition *getWaitCondition() const;
      void setWaitCondition(QWaitCondition *value);
      bool getShouldPause() const;
  
  #endif // THREADWORKER_H
  </code></pre>
  
  <p>When compiling, I am running into this error:</p>
  
  <pre><code>debug/threadworker.o: In function `ZN14QInterruptableD2Ev':
  C:\Users\CybeX\QtProjects\build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../qMyAwesomeApp/3rd-party/QThreading/QThreading/QInterruptable.h:9: undefined reference to `vtable for QInterruptable'
  debug/threadworker.o: In function `ZN14QInterruptableC2Ev':
  C:\Users\CybeX\QtProjects\build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../qMyAwesomeApp/3rd-party/QThreading/QThreading/QInterruptable.h:4: undefined reference to `vtable for QInterruptable'
  collect2.exe: error: ld returned 1 exit status
  mingw32-make[1]: *** [Makefile.Debug:195: debug/MyAwesomeApp.exe] Error 1
  mingw32-make: *** [Makefile:38: debug] Error 2
  mingw32-make[1]: Leaving directory 'C:/Users/CybeX/QtProjects/build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug'
  09:29:08: The process "F:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
  Error while building/deploying project MyAwesomeApp (kit: Desktop Qt 5.13.1 MinGW 32-bit)
  When executing step "Make"
  </code></pre>
  
  <p>I have look at solutions for implementing C++ interfaces and solutions for <code>undefined references to destructors</code>. I found <a href="https://stackoverflow.com/a/13444839/4628115">this</a>, and <a href="https://stackoverflow.com/a/31571012/4628115">this</a>, and <a href="https://stackoverflow.com/a/18302637/4628115">this</a> that reference my issue in particular.</p>
  
  <p>As you can see, I have tried defining the destructor with</p>
  
  <pre><code>virtual ~QInterruptable(){
  
  }
  </code></pre>
  
  <p>which results in the error above.</p>
  
  <p>If I use a pure virtual desctructor like this:</p>
  
  <pre><code>virtual ~QInterruptable() = 0;
  </code></pre>
  
  <p>then I pass the problem on the the child class i.e. <code>ThreadWorker</code> with the following error:</p>
  
  <pre><code>debug/threadworker.o: In function `ZN12ThreadWorkerC2EP7QObject':
  C:\Users\CybeX\QtProjects\build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../qMyAwesomeApp/3rd-party/QThreading/QThreading/threadworker.cpp:28: undefined reference to `QInterruptable::~QInterruptable()'
  debug/threadworker.o: In function `ZN12ThreadWorkerC2ESt8functionIFvvEE':
  C:\Users\CybeX\QtProjects\build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../qMyAwesomeApp/3rd-party/QThreading/QThreading/threadworker.cpp:33: undefined reference to `QInterruptable::~QInterruptable()'
  debug/threadworker.o: In function `ZN12ThreadWorkerD2Ev':
  C:\Users\CybeX\QtProjects\build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../qMyAwesomeApp/3rd-party/QThreading/QThreading/threadworker.cpp:37: undefined reference to `QInterruptable::~QInterruptable()'
  debug/threadworker.o: In function `ZN14QInterruptableC2Ev':
  C:\Users\CybeX\QtProjects\build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug/../qMyAwesomeApp/3rd-party/QThreading/QThreading/QInterruptable.h:4: undefined reference to `vtable for QInterruptable'
  collect2.exe: error: ld returned 1 exit status
  mingw32-make[1]: *** [Makefile.Debug:195: debug/MyAwesomeApp.exe] Error 1
  mingw32-make: *** [Makefile:38: debug] Error 2
  mingw32-make[1]: Leaving directory 'C:/Users/CybeX/QtProjects/build-MyAwesomeApp-Desktop_Qt_5_13_1_MinGW_32_bit-Debug'
  09:33:51: The process "F:\Qt\Qt5.13.1\Tools\mingw730_32\bin\mingw32-make.exe" exited with code 2.
  Error while building/deploying project MyAwesomeApp (kit: Desktop Qt 5.13.1 MinGW 32-bit)
  When executing step "Make"
  </code></pre>
  
  <p>where the offending <code>ThreadWorker.cpp</code> lines are:</p>
  
  <pre><code>[28] ThreadWorker::ThreadWorker(QObject *parent) : QObject(parent)
  [29] {
  [30]     waitCondition = new QWaitCondition;
  [31] }
  [32] 
  [33] ThreadWorker::ThreadWorker(std::function&lt;void ()&gt; func): runnable(func) {
  [34]     waitCondition = new QWaitCondition;
  [35] }
  [36] 
  [37] ThreadWorker::~ThreadWorker()
  [38] {
  [39]     if(waitCondition != nullptr){
  [40]         delete waitCondition;
  [41]     }
  [42] }
  </code></pre>
  
  <p>How can I resolve this undefined reference to the interface destructor issue?</p>