undefined reference to vtable for …

前端 未结 4 1439
余生分开走
余生分开走 2021-01-13 03:42

I am trying to write an Http proxy that basically works like indianwebproxy

So i fired up qtcreator and but one of my classes is failing to compile with the infamous

4条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 03:52

    The destructor is implicitly virtual because a base class has a virtual d'tor.

    The GNU compiler emits the vtable along with the first non-inline virtual method ("key method"). As your d'tor is defined inside the class, it is implicitly virtual, and as there are no other virtual methods, you don't have a key method.

    There is no use case where a concrete class would have only virtual inline methods, as they can be inlined only into derived classes.

    I'd move the definition of the dtor to the implementation file.

    I'm not sure whether you need to use moc here as well, or if QThread derivatives work without (IIRC you need it only for Qt's cast operators, and for signals/slots).

提交回复
热议问题