Android NDK +两个共享库+ RTTI +动态强制转换=不可能 [英] Android NDK + Two Shared Libraries + RTTI + Dynamic cast = Impossible

查看:115
本文介绍了Android NDK +两个共享库+ RTTI +动态强制转换=不可能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我在星期天已经在这里呆了4个小时.我要放弃了实际上,我已经尝试过在互联网上找到的每条帖子,但这只会..不..工作!

I've been at this for 4 hours so far on a Sunday. I'm about to give up. I've tried literally every post I've found on the internet and this simply will..not..work!

任何带有引用或指针的 dynamic_cast 实例返回null或完全崩溃会使我的程序崩溃.对于我的整个应用程序体系结构,这绝对是100%至关重要的,如果我无法做到这一点,我可能只需要进入200 MB静态库即可.

Any instance of dynamic_cast with references or pointers either returns null or flat-out crashes my program. This is absolutely 100% critical to my entire application architecture, and I may just have to go to 200 MB static libs if I can't get this going.

我正在使用 -frtti (没有-fno-rtti)进行构建,并与 -Wl,-export-dynamic 链接(也尝试过 rdynamic).

I'm building with -frtti (there's no -fno-rtti), and linking with -Wl,-export-dynamic (also tried rdynamic) on all my libraries.

我还通过使用自己的 dlopen(fn,RTLD_NOW | RTLD_GLOBAL)手动覆盖了Java的 loadLibrary(),以打开每个库(我尝试了所有可能的方法标志的组合.

I've also manually overrode Java's loadLibrary() by using my own dlopen(fn, RTLD_NOW | RTLD_GLOBAL) to open each lib (I've tried every possible combination of flags.

这根本不可能吗?将其留给android来使用,在整个其他平台上对我来说已经工作了整整十年的事情都变成了无法解决的巨大问题.

Is this simply not possible? Leave it to android to take something that has worked well for me for an entire decade on other platforms and turn it into a huuuuge problem that cannot be solved.

推荐答案

这可能是

This is probably https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md#rtti_exceptions-not-working-across-library-boundaries. The C++ ABI makes it tricky to get RTTI right when dynamically loading libraries. Each of your types must have a key function (a virtual, non-inline, non-destructor method) for RTTI to work across shared library boundaries.

这篇关于Android NDK +两个共享库+ RTTI +动态强制转换=不可能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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