[英]dynamic_cast fails between “long distance” siblings on linux compilation
There is a class DerivedClass which inherits from both BaseClassA and BaseClassB publicly. 有一个DerivedClass类,它公开地继承自BaseClassA和BaseClassB 。 All classes have virtual functions to make sure the virtual table is built properly.
所有类都具有虚函数,以确保正确构建了虚拟表。
BaseClassA and BaseClassB are located in Library1 and DerivedClass is in Library2 . BaseClassA和BaseClassB位于Library1中 , DerivedClass位于Library2中 。
One function in Library1 retrieves a DerivedClass in the form of a BaseClassA pointer and tries to dynamic_cast to BaseClassB but it fails. Library1中的一个函数以BaseClassA指针的形式检索DerivedClass ,并尝试dynamic_cast到BaseClassB,但失败。 The same function works in different environments and compilers (visual studio for instance).
相同的功能可在不同的环境和编译器(例如Visual Studio)中工作。
Extra information: 额外的信息:
I figured it might be one of the following problems 我认为这可能是以下问题之一
Been farming the web trying to find a solution. 一直在网上寻找解决方案。 But what I want to know first is What Is The Problem?
但是我首先要知道是什么问题? How can I focus on it?
我如何专注于它?
(5) looks promising even though I didnt manage to use it. (5)看起来很有希望,即使我没有设法使用它。
Any suggestions would be greatly appreciated (a solution would be great as well ;) ) 任何建议将不胜感激(一个解决方案也将很不错;))
Apparently #4 was the answer. 显然,答案是4。 The was a hidden feature that loads functions dynamically and had to be handles separately.
这是一个隐藏的功能,可以动态加载功能,并且必须分别进行处理。 Adding the -Wl,-E flags to the linking process and changing the loader flags did the trick.
在链接过程中添加-Wl,-E标志并更改加载程序标志就可以了。
What I want to know if there is any linuxy way of understanding this is the error. 我想知道是否有任何Linuxy方式来理解这是错误。
Something like "ldd" command or others (top, nm, readelf, etc) that I tried but couldn't see anything that pointed to this exact error. 我尝试过类似“ ldd”命令或其他命令(top,nm,readelf等),但看不到任何指向此确切错误的东西。
Thanks SOF for continuous help in various subjects 感谢SOF在各个主题上的不断帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.