I'm trying to compile STXXL under Android NDK r8b (I have the same problem under the newer r8c btw).
I'm compiling using gnustl_static.
I need C++11 support so initially I tried setting
LOCAL_CPPFLAGS := -std=c++11
but this threw up an error about uint64_t.
So I changed the flag to
LOCAL_CPPFLAGS :=-std=gnu++11
This helps a fair bit but when it starts compiling I get an error relating to the gnu stl.
Users/Gozzeh/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/stxxl/STXXL/algo/copy_and_sort_file.o.d -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -I/Users/Gozzeh/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include -I/Users/Gozzeh/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include -Ijni -DANDROID -Wa,--noexecstack -fexceptions -frtti -Dnullptr=0 -D_ANDROID -std=gnu++11 -Ijni/STXXL/include -fexceptions -O2 -DNDEBUG -g -I/Users/Gozzeh/android-ndk-r8b/platforms/android-8/arch-arm/usr/include -c jni/STXXL/algo/copy_and_sort_file.cpp -o ./obj/local/armeabi/objs/stxxl/STXXL/algo/copy_and_sort_file.o
In file included from /Users/Gozzeh/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/set:60:0,
from jni/STXXL/include/stxxl/bits/io/simdisk_file.h:33,
from jni/STXXL/include/stxxl/bits/io/io.h:20,
from jni/STXXL/include/stxxl/io:13,
from jni/STXXL/algo/copy_and_sort_file.cpp:18:
/Users/Gozzeh/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h: In member function 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Base_ptr, const _Val&)':
/Users/Gozzeh/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h:1011:39: error: '_Arg' was not declared in this scope
I also get a whole load more errors relating to this _Arg parameter.
So looking at the first one the function looks like the following:
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template<typename _Arg>
#endif
typename _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, _Arg&& __v)
#else
_M_insert_(_Const_Base_ptr __x, _Const_Base_ptr __p, const _Val& __v)
#endif
{
bool __insert_left = (__x != 0 || __p == _M_end()
|| _M_impl._M_key_compare(_KeyOfValue()(__v),
_S_key(__p)));
// This line is the error location.
_Link_type __z = _M_create_node(_GLIBCXX_FORWARD(_Arg, __v));
_Rb_tree_insert_and_rebalance(__insert_left, __z,
const_cast<_Base_ptr>(__p),
this->_M_impl._M_header);
++_M_impl._M_node_count;
return iterator(__z);
}
I can't really understand where the problem is arising. Is gnu++11 not defining __GXX_EXPERIMENTAL_CXX0X__
? Or is the problem that it's not being used somewhere properly? I'm very confused as to what is causing the problem? I have STXXL compiling with gnu++11 under clang on the iphone but I guess that iphone is probably using a different STL implementation. Has anyone got any ideas on how I can fix this problem?
If you need any further info just ask!
Edit: So further to one of the comments here is my application.mk
APP_PLATFORM := android-8
APP_STL := gnustl_static
APP_GNUSTL_FORCE_CPP_FEATURES := exceptions rtti
APP_OPTIM := release APP_ABI := all
and this is my android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
rwildcard = $(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
LOCAL_MODULE := stxxl
LOCAL_CPP_FEATURES += exceptions
FILE_LIST := $(call rwildcard, $(LOCAL_PATH)/STXXL/,*.cpp)
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_CPPFLAGS := -Dnullptr=0 -D_ANDROID -D__STDC_INT64__ -std=gnu++11 -I$(LOCAL_PATH)/STXXL/include
include $(BUILD_SHARED_LIBRARY)
Edit: Interestingly I just tried placing a #error temp
inside the #ifdef __GXX_EXPERIMENTAL_CXX0X__
block in the stl_tree.h function i posted. The compiler does NOT throw an error on that part ... so the define is never getting set which is, presumably, the cause of my issues. I've also specifically added a -D__GXX_EXPERIMENTAL_CXX0X__
but that makes no difference (its as if it gets undef'd).