调试 GCC 中的 vtable 链接器错误
当使用 GCC 时,我时不时地会遇到这样的神秘错误:
undefined reference to 'vtable for classname'
当它不是由缺少库引起时,这个描述性不太强的错误消息总是让我逐行挖掘代码文件找到虚函数缺少的实现。有没有办法让链接器告诉我它缺少哪个虚拟函数,也许是一个标志或其他东西?或者它可能告诉我但我不明白它在说什么?
Now and then when using GCC I get cryptic errors like this:
undefined reference to 'vtable for classname'
When it's not caused by a missing library, this not-very-descriptive error message always causes me to dig through code files line by line to find the missing implementation for a virtual function. Is there a way to make the linker tell me which virtual function it is missing, perhaps a flag or something? Or is it maybe telling me but I don't understand what it's saying?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 gcc 常见问题解答:
我采用的解决方案是搜索类名并查找虚拟方法声明并检查是否有定义。我没有找到任何其他解决方案。
From gcc faq:
The solution that I adopt is search the classname and seek virtual methods declaration and check if there is any definition. I didn't found any other solution for this.