user1279988
user1279988

Reputation: 763

some c++ include file in Android NDK does not work

I am using android JNI to use some c++ code. but how should I cope with the problem of The android jni does not recognize the include file in c++ version's some include file:

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

so some code of reading file can not use

for example :istream ,getline(), string, how should I find alternate solution?

and some transfer function ,std::stoull( std::wstring& ), atof, and so on , which are trivial to my module,

Did anyone have similar experience?

Upvotes: 0

Views: 1289

Answers (1)

Michael
Michael

Reputation: 58467

You need to define an appropriate C++ runtime to use in your Application.mk.

For example:

APP_STL := gnustl_static


Quoting from 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.

The default if you don't specify which one to use is system, which only provides the following STL headers:

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

Upvotes: 2

Related Questions