java - Android NDK 中的某些 C++ 包含文件不起作用

标签 java android c++ android-ndk java-native-interface

我正在使用 android JNI 来使用一些 c++ 代码。但我该如何应对 android jni无法识别c++版本的一些include文件中的include文件:

#include <string>
#include <iostream>
#include <fstream>

所以有些读取文件的代码不能用

例如:istream ,getline(), string,我应该如何找到替代解决方案?

和一些传递函数,std::stoull( std::wstring& ),atof,等等, 这对我的模块来说是微不足道的,

有没有人有类似的经历?

最佳答案

您需要定义适当的 C++ 运行时以在您的 Application.mk 中使用。

例如:

APP_STL := gnustl_static


引用自 docs/CPLUSPLUS-SUPPORT.html:

To select the runtime you want to use, define APP_STL inside your Application.mk to one of the following values:

system -> Use the default minimal system C++ runtime library.
gabi++_static -> Use the GAbi++ runtime as a static library.
gabi++_shared -> Use the GAbi++ runtime as a shared library.
stlport_static -> Use the STLport runtime as a static library.
stlport_shared -> Use the STLport runtime as a shared library.
gnustl_static -> Use the GNU STL as a static library.
gnustl_shared -> Use the GNU STL as a shared library.

如果您不指定使用哪一个,则默认为 system,它仅提供以下 STL header :

cassert cctype cerrno cfloat climits cmath csetjmp csignal
cstddef cstdint cstdio cstdlib cstring ctime cwchar new stl_pair.h
typeinfo utility

关于java - Android NDK 中的某些 C++ 包含文件不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20514491/

相关文章:

JavaFX - 加载图像和内存问题

java - Apache Felix Web 控制台 404

android - 缩小时聚类 map 标记,放大时取消聚类

c++ - 将 get_value 与 Boost 的属性树一起使用时出现问题

C++ 异常问题

java - 替换字符串中的特殊字符

java - 单线程服务器实现多线程

Android 动画仅在滚动其父 View 后才开始

Android 电池广播

c++ - 纯虚函数的模板特化