1. 程式人生 > >ndkbuild c++ string 'string' is not a member of 'std' 'string' was not declared in this scope

ndkbuild c++ string 'string' is not a member of 'std' 'string' was not declared in this scope

最近使用ndk時,

#include <string>

ndkbuild編譯後報錯:fatal error: string: No such file or directory

#include <string.h>

std::string 編譯報錯:error: 'string' is not a member of 'std'

解決辦法:

需要讓Android NDK支援STL

Application.mk中加入:APP_STL := stlport_static

如下:

#include <string>

std::string s;

或者使用名稱空間 using namespace std;