简体   繁体   中英

Include ICU in Android NDK Project

I built a library in C++ that I want to include in my Android application using the NDK. However, my library needs to use ICU4C. I have been trying to compile ICU for Android, and I looked at a lot of questions here on SO, but I am still unable to get ICU compiled into .a files for Android. I'm not sure the best way to do this. Has anyone had success with ICU with the NDK?

By the way, I was hoping to use ICU 51.2, unless there's a good reason to use an older version.

You can build ICU as Android static library by specifying these flags in your Android.mk

LOCAL_CFLAGS := -DANDROID -fdata-sections -ffunction-sections
LOCAL_CPPFLAGS := -DANDROID -frtti -fno-exceptions -fdata-sections -ffunction-sections

If you use Android NDK without exceptions you will need to hack the missing cxa_bad_typeid()

extern "C" std::type_info const& __cxa_bad_typeid()
{
   // just return something
   return typeid(void*);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM