未定义符号“vtable for ...”和“typeinfo for ...”。 [英] Undefined symbols "vtable for ..." and "typeinfo for..."?

查看:2209
本文介绍了未定义符号“vtable for ...”和“typeinfo for ...”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几乎最后一步,但还是有一些奇怪的错误....

Nearly the final step but still some strange erros....

bash-3.2$ make
g++ -Wall -c -g Myworld.cc
g++ -Wall -g solvePlanningProblem.o Position.o AStarNode.o PRM.o PRMNode.o World.o SingleCircleWorld.o Myworld.o RECTANGLE.o CIRCLE.o -o solvePlanningProblem
Undefined symbols:
  "vtable for Obstacle", referenced from:
      Obstacle::Obstacle()in Myworld.o
  "typeinfo for Obstacle", referenced from:
      typeinfo for RECTANGLEin RECTANGLE.o
      typeinfo for CIRCLEin CIRCLE.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [solvePlanningProblem] Error 1

vtable和typeinfo的含义是什么?

What's the meaning of vtable and typeinfo?

推荐答案

如果Obstacle是一个抽象基类,那么请确保声明所有虚拟方法pure virtual:

If Obstacle is an abstract base class, then make sure you declare all its virtual methods "pure virtual":

virtual void Method() = 0;

= 0 告诉编译器方法必须被派生类覆盖,并且可能没有自己的实现。

The = 0 tells the compiler that this method must be overridden by a derived class, and might not have its own implementation.

如果类包含任何非纯虚函数,那么编译器将假设它们在某处具有实现,并且其内部结构(vtable和typeinfo)可以在与其中之一相同的目标文件中生成;如果这些函数没有实现,那么内部结构将会丢失,你会得到这些错误。

If the class contains any non-pure virtual functions, then the compiler will assume that they have an implementation somewhere, and its internal structures (vtable and typeinfo) might be generated in the same object file as one of those; if those functions are not implemented, then the internal structures will be missing and you will get these errors.

这篇关于未定义符号“vtable for ...”和“typeinfo for ...”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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