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.
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)
Here is what is in my Application.mk
file:
NDK_TOOLCHAIN_VERSION=4.7
APP_STL := stlport_shared
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
.
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'
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.
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?