Android NDK 编译出现 string:No such file or directory
2016-12-23 13:33
411 查看
Android NDK 'std::string' has not been declared
U_U 2013-02-03
22:02:38
最近使用NDK, 在C++头文件中加入
#include <string>
ndk-build后报错
x.h: fatal error: string: No such file or directory
试着换成
#include <string.h>
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
头文件中#include <string>就OK了, 注意使用std::string或加上using namespace std;
#include <string>
using namespace std;
class X {
public:
void a(string);
void b(std::string);
};
相关文章推荐
- Android NDK 编译出现 atomic :No such file or directory
- 编译Linux内核时出现“fatal error: linux/netfilter/xt_dscp: No such file or directory”
- BUG:给Nexus7编译Android4.2的时候出现 fatal error: map: No such file or directory
- VS2008中编译C工程出现无法打开包括文件:“iostream.h”: No such file or directory
- Erlang 编译时出现"no such file or directory" 与 当前工作目录问题
- 编译GCC-4.8出现的错误 —— Linux gnu/stubs-32.h: No such file or directory
- 编译内核,出现gcc: error: elf_i386: No such file or directory
- 编译Linux内核时出现错误gcc: error: elf_i386: No such file or directory
- 编译Linux内核时出现错误gcc: error: elf_i386: No such file or directory
- Qt5编译时出现<QtGui/QApplication> ---> No such file or directory错误解决办法
- .NET下编译C++代码时出现fatal error C1083: 无法打开包含文件:“iostream.h”: No such file or directory错误的解决方法.
- Erlang 编译时出现"no such file or directory" 与 当前工作目录问题
- 编译jabberd 2出现expat.h: No such file or directory
- 引用原因.NET下编译C++代码时出现fatal error C1083: 无法打开包含文件:“iostream.h”: No such file or directory错误的解决方法.
- VC编译时出现 cannot open file '.'.\Debug\Test1.sbr': No such file or directory 怎么关闭Browser Info
- mingw中编译库出现sys/times.h: No such file or directory的可行解决方法
- BUG:给Nexus7编译Android4.2的时候出现 fatal error: map: No such file or directory
- .NET下编译C++代码时出现fatal error C1083: 无法打开包括文件:“xuhk_JNIHelloWorld.h”: No such file or directory错误的解决方法。
- Cygwin中用NDK来编译程序出现"No such file or directory"问题
- 编译WINCE应用出现:Cannot open include file: 'ceconfig.h': No such file or directory