c ++缺少vtable错误 [英] c++ a missing vtable error

查看:136
本文介绍了c ++缺少vtable错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个真正奇怪的错误相关的一个给定的类构造函数和析构函数缺少vtable。请帮助我解决这个问题。



建筑i386的未定义符号:

 vtable for A,引用自:
A :: A()在Ao
A ::〜A中的MissionController()A
注意:缺少的vtable通常意味着第一个-inline virtual member function没有定义。
ld:没有为架构i386找到符号
clang:error:linker命令失败,退出代码1(使用-v查看调用)

代码段;



.h文件:



  class A:public B 

public:
A();
〜A();

};



.cpp文件..



  A :: A()
{


}

A ::〜A b {


}


解决方案>

啊!在这个问题上,我想我得到了发生了什么。我注意到 CCNode 是属于别人的代码。



你继承的任何虚函数也是虚拟的在派生类...和通常的做法是使析构函数虚拟...你可能不会意识到析构函数是虚拟的。



此外,如果你使用某人else的头文件,但忘记链接到它们的目标文件,它可能会导致这个错误,因为链接器将缺少 CCNode 的析构函数。


I am getting a really weird error related to missing vtable for a given class constructor and destructor. Please help me to resolve this.

Undefined symbols for architecture i386:

  "vtable for A", referenced from:
      A::A() in A.o
      A::~MissionController() in A.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Code snippet;

.h file:

class A: public B

  public:
     A();
    ~A();

};

.cpp file..

 A::A()   
{


}

A::~A()
{


}

解决方案

Ah! Mulling on this I think I get what is happening. I'm betting that CCNode is code which belongs to somebody else.

Any virtual functions you inherit are also virtual in the derived class... and it is common practice to make the destructor virtual... you might not realise the destructor is virtual.

Also if you are using somebody else's header file, but forgot to link to their object file, it might cause this error, as the linker would be missing the destructor of CCNode.

这篇关于c ++缺少vtable错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆