Wednesday, April 4, 2012

Android NDK C++ Exceptions and RTTI Link Errors

When using Android NDK to build performance-critical portions of Android apps in native C++ code, we may get C++ link errors such as:
  • undefined reference to `__cxa_end_cleanup'; 
  • undefined reference to `__gxx_personality_v0'; 
  • undefined reference to `vtable for __cxxabiv1::__si_class_type_info'; 
  • undefined reference to `vtable for __cxxabiv1::__class_type_info'.
The first two errors are caused by no exceptions support in Android NDK toolchain, and the last two errors are caused by no RTTI support in the toolchain, according to the latest Android NDK release note STANDALONE-TOOLCHAIN.html under the docs directory. The documentation also mentioned any C++ STL (either STLport or the GNU libstdc++) with it are also not supported.

To get around the above linking errors, add compile flags 
  • -fno-exceptions to disable exceptions
  • -fno-rtti to turn off RTTI

No comments:


Blog Archive

About Me

My photo
HD Multimedia Technology player