c++ - Weird linker error undefined reference to vtable -


i have class no virtual function, class contains class, here definitions:

class storagemanager : public qobject {     q_object protected:      class abstractwrapper {     public:         virtual void action1() = 0;         virtual void action2() = 0;         virtual void action3() = 0;         virtual ~abstractwrapper() {}     };      class abstractstorage {     public:         virtual qsharedpointer<abstractwrapper> getwrapper(qstring key) = 0;         virtual qsharedpointer<abstractwrapper> newwrapper(qstring key) = 0;         virtual void deletewrapper(qstring key) = 0;         virtual ~abstractstorage() {}     };      template<typename t>     class wrapper {     public:         virtual void action1() { /* stuff */ }         virtual void action2() { /* stuff */ }         virtual void action3() { /* stuff */ }         virtual ~wrapper() {}     private:         t * realcontent;     };      template<typename t>     class storage {     public:         virtual qsharedpointer<abstractwrapper> getwrapper(qstring key)         {             return new wrapper<t>(storage.value(key));         }         virtual qsharedpointer<abstractwrapper> newwrapper(qstring key)         {             t * tmp = new t();              qobject::connect(tmp,         signal(signal(int)),                              &dispatcher, slot(slot(int)));             storage.insert(key, tmp);             return new wrapper<t>(tmp);         }          virtual void deletewrapper(qstring key)         {             t * tmp = storage.value(key);             disconnect(tmp, signal(signal(int)),                        &dispatcher, slot(slot(int)));             delete tmp;             storage.remove(key);         }          virtual ~storage() {}     private:         qhash<qstring, t *> storage;     };  private:      static storage<classa> classastorage;     static storage<classb> classbstorage;     static storage<classc> classcstorage;      static storagemanager dispatcher;  public:     static abstractstorage * getstorage(int classid)     {              if(classid == 'a') return &classastorage;         else if(classid == 'b') return &classbstorage;         else if(classid == 'c') return &classcstorage;         else throw std::exception();     }      public void connectdispatcher(qobject * receiver, const char * method)     {         connect(&dispatcher, signal(dispatch_signal(int)), receiver, method);     }  public slots:     void slot(int output)     {         emit dispatch_signal(output);     }  signals:     void dispatch_signal(int);  } 

i have .cpp file static initiliazations.

when compiling have no compilation errors. 1 linker errors :

undefined reference `vtable storagemanager' 

this error labeled on class definition line :

class storagemanager : public qobject { 

i know kind of error related pure virtual member not overloaded, don't see errors in code...

thanks help


edit:

answer: file not compiled moc. solution: delete file project, add same class using "add new...", "c++ class". triple check choose qobject parent class.

this qtcreator related bug, appens qtcreator 3.3.2 revision 3af3fe7ad3

solution found !

the header file not compiled moc compiler in .pro file.

to solve problem: delete header , source file project. clean project. build project.

then add class using qtcreator assistant :

  • add new...
  • c++ class
  • name class , choose qobject base class

then rebuild project, should fine.


this qtcreator related bug, appens qtcreator 3.3.2 revision 3af3fe7ad3.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -