智能指针不与Android NDK R8工作 [英] smart pointers not working with Android NDK r8

查看:455
本文介绍了智能指针不与Android NDK R8工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚如何我的Andr​​oid项目中使用共享指针。我使用的是Mac OS X上最新的Eclipse ADT与Android NDK r8d。

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.

我能使用lambda表达式和C ++ 11标准,自动所以C ++ 11的标志似乎是工作。不过只要我尝试使用一个shared_ptr,weak_ptr的,或者的unique_ptr,我得到的错误'suchandsuch_ptr'不是'性病'搜索

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'

我有的#include<存储器GT; 在我的cpp文件。现在Eclipse的告诉我,未解决的包容:其中,存储> ,但我得到了同样的事情<载体> <字符串方式> 以及那些似乎编译和工作得很好结果

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和铿锵者有很长一段时间的智能指针的支持,这将意味着,我要么缺少的东西,或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 /来源/ CXX-STL / GNU-的libstdc ++ / 4.7 /包括)在目标设置。

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识别C ++ 11类在GNU标准库,添加 __ __ GXX_EXPERIMENTAL_CXX0X 为predefined宏索引。 (这个名字是因为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工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆