Undefined reference to vtable

前端 未结 16 2146
死守一世寂寞
死守一世寂寞 2020-11-21 20:30

When building my C++ program, I\'m getting the error message

undefined reference to \'vtable...

What is the cause of this probl

16条回答
  •  后悔当初
    2020-11-21 21:34

    So I was using Qt with Windows XP and MinGW compiler and this thing was driving me crazy.

    Basically the moc_xxx.cpp was generated empty even when I was added

    Q_OBJECT

    Deleting everything making functions virtual, explicit and whatever you guess doesn't worked. Finally I started removing line by line and it turned out that I had

    #ifdef something
    

    Around the file. Even when the #ifdef was true moc file was not generated.

    So removing all #ifdefs fixed the problem.

    This thing was not happening with Windows and VS 2013.

提交回复
热议问题