我正在使用 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/