smart pointers not working with Android NDK r8(智能指针不适用于 Android NDK r8)
问题描述
我不知道如何在我的 Android 项目中使用共享指针.我在带有 Android NDK r8d 的 Mac OS X 上使用最新的 Eclipse ADT.
I can't figure out how to use shared pointers within my Android project. I'm using the latest Eclipse ADT on Mac OS X with the Android NDK r8d.
这是我的 Android.mk
文件中的内容:
Here is what is in my Android.mk
file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_CPPFLAGS := -std=c++11
LOCAL_MODULE := native
LOCAL_SRC_FILES := native.cpp
include $(BUILD_SHARED_LIBRARY)
这是我的 Application.mk
文件中的内容:
Here is what is in my Application.mk
file:
NDK_TOOLCHAIN_VERSION=4.7
APP_STL := stlport_shared
我已经尝试过默认的 GCC 4.6、实验性 4.7 和 clang3.1 工具链.
我尝试链接到 stlport_shared
和 gnustl_shared
c++ 运行时库.
我试过 FLAGS
-std=c++11
、-std=c++0x
和 -std=gnu++11
.
I've tried the default GCC 4.6, the experimental 4.7, and the clang3.1 toolchains.
I've tried linking to stlport_shared
and gnustl_shared
c++ runtime libraries.
I've tried the FLAGS
-std=c++11
, -std=c++0x
, and the -std=gnu++11
.
我能够使用 c++11 标准的 lambdas 和 auto,因此 C++11 标志似乎正在工作.但是,每当我尝试使用 shared_ptr、weak_ptr 或 unique_ptr 时,我都会收到错误 'suchandsuch_ptr' is not a member of 'std'
I'm able to use lambdas and auto of the c++11 standard, so the C++11 flag appears to be working. However anytime I try and use a shared_ptr, weak_ptr, or unique_ptr, I get the error 'suchandsuch_ptr' is not a member of 'std'
我的 cpp 文件中有 #include <memory>
.现在 Eclipse 告诉我 未解决的包含:<memory>
,但对于 <vector>
和 <string>
和这些似乎编译和工作都很好.
I have the #include <memory>
in my cpp file. Now Eclipse tells me Unresolved inclusion: <memory>
, but I get the same thing for <vector>
and <string>
and those appear to compile and work just fine.
Android NDK 中包含的工具链中是否没有实现智能指针?
如果不是,为什么不呢?由于 GCC 和 clang 支持智能指针已经有一段时间了,这意味着我要么遗漏了一些东西,要么 Android 开发人员出于某种原因禁用了它们.
有什么线索吗?
Are smart pointers not implemented in the toolchains included in the Android NDK?
If not, why not? Since GCC and clang have had support for smart pointers for quite some time, this would mean that I am either missing something, or the Android devs have disabled them for some reason.
Any clues?
推荐答案
确保标准库包含路径(如 /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.
要让 IDE 识别 GNU 标准库中的 C++11 类,请将 __GXX_EXPERIMENTAL_CXX0X__
作为预定义宏添加到索引器.(这个名字有点不合时宜,因为 C++11 是标准化的,并且支持不再是实验性的,但到目前为止还是这么称呼的.)另外,请确保索引器设置为反映正确的构建目标.
To get the IDE to recognize C++11 classes in the GNU standard library, add __GXX_EXPERIMENTAL_CXX0X__
as a predefined macro to the indexer. (The name is a bit of anachronism since C++11 is standardized and the support is no longer experimental, but as yet that's what it's called.) Also, be sure the indexer is set to reflect the correct build target.
这篇关于智能指针不适用于 Android NDK r8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:智能指针不适用于 Android NDK r8
基础教程推荐
- 使用从字符串中提取的参数调用函数 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 从 std::cin 读取密码 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01