在 Android NDK 项目中包含 ICU

Include ICU in Android NDK Project(在 Android NDK 项目中包含 ICU)
本文介绍了在 Android NDK 项目中包含 ICU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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*);
}

这篇关于在 Android NDK 项目中包含 ICU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to enforce move semantics when a vector grows?(当向量增长时如何强制执行移动语义?)
Typedef function pointer?(typedef函数指针?)
Reflection and refraction impossible without recursive ray tracing?(没有递归光线追踪就不可能实现反射和折射?)
Is delete[] equal to delete?(delete[] 是否等于删除?)
Why is unsigned integer overflow defined behavior but signed integer overflow isn#39;t?(为什么定义了无符号整数溢出行为但没有定义有符号整数溢出?)
Unions and type-punning(工会和类型双关语)