[android]std::map 链接器错误 ndk r8c 与 APP_STL: = gnustl_static

标签:  android-ndk  C++  Android
发布时间: 2014/9/20 9:46:24
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.

我有一些问题链接 STL 的故乡 application 。连接失败时的 map::insert 与 map::operator [] 成功与其他映射函数。我 Application.mk 是:

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

本机代码包含两个文件夹级别。对于每个内部的文件夹,我创建了一个 Android.mk 文件来编译和生成的静态库。我使用 std::map 在最深的文件夹中。Android.mk 看起来像:

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)

当我 build 项目得到了以下错误:

~/.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*)'

我的很多伊格错了吗?

多谢。

解决方法 1:

我发现了一种变通方法来编译项目。

LOCAL_LDLIBS += ~/.android-ndk-r8c/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libsupc++.a
LOCAL_LDLIBS
+= ~/.android-ndk-r8c/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/libgnustl_static.a
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页