From fabrice.mousset at geocept.com Tue Aug 6 08:51:05 2019 From: fabrice.mousset at geocept.com (Fabrice Mousset | GEOCEPT GmbH) Date: Tue, 6 Aug 2019 06:51:05 +0000 Subject: [Android-development] Qt 5.12.4 for Android and Segmentation fault on dynamic_cast Message-ID: Hi all, I am a C++ programmer but far away to be an expert, so I need some help to understand and I hope, to solve this issue! I am working with Qt since 5 years (starting with Qt 5.4). We have developed an embedded application working on WindowsXP/Windows7 and Linux 86/Linux ARM (without display). I the mean time, I have create a small Android App which is a part of the previous developped application (some libraries) and Qt 5.7. Now I am updating Qt version from 5.4.2 to 5.12.4, which is the last LTS, to also running the full application on Android device (Android 9.0) and Windows 7. On Windows, all works fine, but with the Android device I've got an exception when using "dynamic_cast<>()"! To build my application with Qt 5.12.4 for Android ARM, I use: * Windows 7 Pro 64 bit workstation * Oracle Java SDK 1.8.0.121 * Android SDK 25.2.5 * Android NDK 20.0.5594570 I had a little issue with the linker for which I found quickly the solution on Internet: adding "QMAKE_LINK += -nostdlib++" in PRO file. I have a plugin mechanism in the application to enable using specific features base on the hardware capabilities. To define the plugin, I use several interfaces, each one is declared like this: class NAVCOMMONSHARED_EXPORT NavigationInterface { public: virtual ~NavigationInterface() {} virtual void initialize(int type, int width, int height) = 0; ... } And finally, the plugin himself: class NavigationSDK : public QObject , public NavigationInterface , public GeocoderInterface , public MapInterface , public RoutingInterface , public ZoomInterface { Q_OBJECT public: ... }; On the main application side, I load the plugin and create the instance with QPluginLoader. And calling "objectName()" works, I've to the name of my plugin, which is set in the plugin himself. But "auto* navigation = dynamic_cast(m_navPlugin);" generates a segmentation fault exception! What I am doing wrong? I have tried to not have an inline virtual destructor to avoid vtable warnings, but this didn't change anything. Is this an Android-clang specific issue? Is my interface usage/understanding wrong? Do I use bad JDK/NDK/SDK versions? Thank in advance for any help Best regards Fabrice Mousset -------------- next part -------------- An HTML attachment was scrubbed... URL: