10

これらのエラーのいくつかは、変更することで解決されます

    virtual void draw();

    virtual void draw() {};

しかし、これらのエラーの他の原因は何ですか?, 仮想関数以外..次のエラーの原因は何ですか..

  /tmp/cciGEgp5.o:(.rodata._ZTI14CustomXmppPump[typeinfo for CustomXmppPump]+0x18): 
  undefined reference to `typeinfo for XmppPump'
4

2 に答える 2

12

RTTI (-frtti) でコンパイルしている場合は、依存ライブラリも -fno-rtti ではなく RTTI でコンパイルされていることを確認してください。そうしないと、-fno-rtti でコンパイルされたクラスをサブクラス化するか、dynamic_cast を使用するときに、typeinfo エラーが発生します。

于 2015-02-15T00:36:18.120 に答える
7

In GCC, the first non-inline virtual method is used to determine the the translation unit where the vtable and typeinfo objects are created. If you then do not define that method, it creates the error you see, since it expected you define that method somewhere, and was waiting for that definition to emit the output of the vtable and typeinfo for the class.

http://gcc.gnu.org/onlinedocs/gcc/Vague-Linkage.html

When you change the declaration of virtual void draw(); to the inline definition of virtual void draw() {};, it picks a different function to emit the vtable.

于 2012-08-10T15:28:35.347 に答える