How to compile c++11 code with android ndk and eclipse?(如何用android ndk和eclipse编译c++11代码?)
问题描述
我正在使用 android NDK r8d 和 eclipse Juno.我正在尝试在原生 android 项目中编译使用 C++11 内容的 C++ 代码,例如 mutex
、lock_guard
、shared_ptr
等在日食中.
I'm using android NDK r8d, and eclipse Juno. I'm trying to compile C++ code which uses C++11 stuff like mutex
, lock_guard
, shared_ptr
, etc. in a native android project in eclipse.
我收到如下错误:
错误:‘shared_ptr’不是‘std’的成员"
"error: 'shared_ptr' is not a member of 'std'"
致命错误:互斥锁:没有这样的文件或目录"
"fatal error: mutex: No such file or directory"
我在这里遇到了类似的问题.它似乎对他们有用,但那里的解释不完整,所以我无法让它对我有用.
I came across a similar question here. It seems to work for them, but the explanation there is not complete so I can't get it to work for me.
我将 "NDK_TOOLCHAIN_VERSION=4.7"
添加到 Application.mk
和 "LOCAL_CFLAGS += -std=c++11"
到Android.mk
文件.仍然无法编译.
I added "NDK_TOOLCHAIN_VERSION=4.7"
to the Application.mk
and "LOCAL_CFLAGS += -std=c++11"
to Android.mk
file. Still, it doesn't compile.
在上面的链接中说:
"确保标准库包含路径(如/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include) 在目标设置."
"Be sure that the standard library include path (like /android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include) is in the target settings."
如何以及在何处插入?
我还在 Eclipse IDE 中遇到错误(在源代码上,在编译之前).我知道我应该定义 "__GXX_EXPERIMENTAL_CXX0X__"
来解决它们,但我只是不知道把它放在哪里.
I also get errors in eclipse IDE (on the source, before compiling). I know I should define "__GXX_EXPERIMENTAL_CXX0X__"
to resolve them but I just don't know where to put it.
所以,如果有人可以发布一个答案,并完整解释如何编译和使 eclipse 与 C++11 一起工作,那就太好了.
So, if someone could post an answer with a full explanation of how to compile and make eclipse work with C++11 it would be great.
推荐答案
关于你的第一个问题:
转到项目 > 属性 > C/C++ 常规/路径和符号
Go to Project > Properties > C/C++ General / Paths and Symbols
在包含"选项卡中,添加正确的目录,例如/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include
In the "Includes" tab, add the proper directory, e.g. /android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include
关于你的第二个问题,我也在寻找答案.绝对不清楚如何在 Eclipse 中定义 GXX_EXPERIMENTAL_CXX0X 宏.
Regarding your second question, I'm also looking for an answer. It is absolutely not clear how to define the GXX_EXPERIMENTAL_CXX0X macro in Eclipse.
有人说它应该作为预定义的宏添加到索引器中",但看起来我们都找不到实现它的方法......
Some say that it should be "added as a predefined macro to the indexer", but it looks like we both could not find a way to implement that...
我在其他地方读到它应该被添加到C/C++ General/Paths and Symbols/Symbols/GNU C++",但我在我的 Indigo 版本中找不到Symbols/GNU C++"部分.
I have read elsewhere that it should be added to "C/C++ General / Paths and Symbols / Symbols / GNU C++" but I can't find the "Symbols / GNU C++" part in my version of Indigo.
这篇关于如何用android ndk和eclipse编译c++11代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何用android ndk和eclipse编译c++11代码?
基础教程推荐
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01