Tuesday, December 11, 2012

[android-developers] std::map linker error ndk r8c with APP_STL := gnustl_static

Hi,

I have some problem linking the STL in my Native application. Linking fails with both map::operator[] and map::insert while succeeds with other map functions.
My Application.mk is :

APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions -frtti
APP_CPPFLAGS += -g3
APP_CPPFLAGS += -DDEBUG
APP_ABI := armeabi-v7a
APP_PLATFORM:=android-14
NDK_TOOLCHAIN_VERSION:=4.6

The native code contains two folder level. I created for each internal folder an Android.mk file to compile and generate a static library. I'm using std::map in the deepest folder. Android.mk looks like:

TEMP_PATH_REG := $(call my-dir)
LOCAL_PATH := $(TEMP_PATH_REG)
include $(call all-subdir-makefiles)
LOCAL_PATH := $(TEMP_PATH_REG)
include $(CLEAR_VARS)

LOCAL_MODULE            := registration
LOCAL_C_INCLUDES     := $(LOCAL_PATH)/../glm/
LOCAL_SRC_FILES        := registration_factory.cpp \
                                          inertial.cpp                                       
LOCAL_LDLIBS               := -llog -landroid -lEGL
LOCAL_STATIC_LIBRARIES     := android_native_app_glue
include $(BUILD_STATIC_LIBRARY)
$(call import-module,android/native_app_glue)

When I build the project i get the following errors:

~/.android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libregistration.a(registration_factory.o): in function std::_Rb_tree<int, std::pair<int const, xmar::IRegistration*>, std::_Select1st<std::pair<int const, xmar::IRegistration*> >, std::less<int>, std::allocator<std::pair<int const, xmar::IRegistration*> > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair<int const, xmar::IRegistration*> const&):~/.android-ndk-r8c/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h:1013: error: undefined reference to 'std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
StaticLibrary  : libandroid_native_app_glue.a
rm -f obj/local/armeabi-v7a/libandroid_native_app_glue.a
~/.android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libregistration.a(registration_factory.o): in function std::_Rb_tree_const_iterator<std::pair<int const, xmar::IRegistration*> >::operator--():~/.android-ndk-r8c/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h:284: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
~/.android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-ar crs ./obj/local/armeabi-v7a/libandroid_native_app_glue.a ./obj/local/armeabi-v7a/objs-debug/android_native_app_glue/android_native_app_glue.o
~/.android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libregistration.a(registration_factory.o): in function std::_Rb_tree_const_iterator<std::pair<int const, xmar::IRegistration*> >::operator++():~/.android-ndk-r8c/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h:269: error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
Prebuilt       : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/
~/.android-ndk-r8c/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi-v7a/libregistration.a(registration_factory.o): in function std::_Rb_tree_iterator<std::pair<int const, xmar::IRegistration*> >::operator--():~/.android-ndk-r8c/sources/cxx-stl/gnu-libstdc++/4.6/include/bits/stl_tree.h:203: error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'

What i'm doig wrong?
Thanks a lot.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment