最近使用NDK, 在C++头文件中加入
#include
ndk-build后报错
x.h: fatal error: string: No such file or directory
试着换成
#include
ndk-build后继续报错
x.h: error: 'std::string' has not been declared
真是郁闷, 后来在网上搜索了一大圈, 原来是需要让Android NDK支持STL
Import STL libraries to the Android NDK code > This is a quick tip for those who are beginning to write native Android code. > As one may have noticed, it isn’t possible to use containers like, string, vector, list inside the NDK samples. > These are all part of the STL (Standard Template Library), and are expected to be available when writing C++ code. > The Application.mk, works similarly as the Android manifest file for your NDK code, > allowing the programmer to add permissions and define other applications' properties, like such as 'enabling' the STL support. 将Application.mk放在jni目录下(内容如下) APP_STL := stlport_static