Linker Error in STL

1,920 views
Skip to first unread message

vijayasarathy m

unread,
Jun 14, 2013, 12:36:53 AM6/14/13
to andro...@googlegroups.com

Hi All,

I am trying to build ffmpeg with libstagefright enabled for android.
I am able to build ffmpeg libraries separately.
But when I was trying to link the ffmpeg libraries with my Android NDK, I am getting below linker errors.

 error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
 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&)'
 error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
 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&)'
 error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
 error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
 error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
 error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
 error: undefined reference to 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)'
 error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'
 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&)'
 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&)'
 error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
 error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'
 error: undefined reference to 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'

All the errors are in stl_tree.h

In Application.mk, I have tried using both stlport_static and gnustl_static

I am using Android NDK r8e (android-ndk-r8e)

Please let me know how to resolve this Linker errors.

Thanks & Regards,
Vijayasarathy.M

Ben Pope

unread,
Jun 14, 2013, 3:14:42 AM6/14/13
to andro...@googlegroups.com
On 14/06/13 12:36, vijayasarathy m wrote:
>
> Hi All,
>
> I am trying to build ffmpeg with libstagefright enabled for android.
> I am able to build ffmpeg libraries separately.
> But when I was trying to link the ffmpeg libraries with my Android NDK,
> I am getting below linker errors.
>
> */ error: undefined reference to
> 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'/*
> */ 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&)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'/*
> */ 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&)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_rebalance_for_erase(std::_Rb_tree_node_base*,
> std::_Rb_tree_node_base&)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_decrement(std::_Rb_tree_node_base const*)'/*
> */ 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&)'/*
> */ 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&)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_increment(std::_Rb_tree_node_base const*)'/*
> */ error: undefined reference to
> 'std::_Rb_tree_decrement(std::_Rb_tree_node_base*)'/*
> */
> /*
> All the errors are in *stl_tree.h*
>
> In Application.mk, I have tried using both *stlport_static
> and gnustl_static*

Well, which headers did you point your compiler to when you built
ffmpeg? The implementation of the std libraries is free to differ (as
you can see, the undefined symbols are using reserved names), as long as
the external C++ interface is compatible.

When you build ffmpeg, you'll need to point the compiler to the headers
for the std library you wish to link to.

Ben


vijayasarathy m

unread,
Jun 14, 2013, 3:50:42 AM6/14/13
to andro...@googlegroups.com

Thanks Ben,
Actually I have linked with gnustl_shared in ffmpeg and trying to link gnustl_static in NDK.
Now I have changed gnustl_static to gnustl_shared in Application.mk
NDK is built successfully.

But When running the application, I am getting unsatisfied link error.

E/AndroidRuntime( 5424): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1936]:   129 could not load needed library 'libgnustl_shared.so' for 'libnative-ffplayer.so' (load_library[1091]: Library 'libgnustl_shared.so' not found)

I am even loading the library explicitly. Still facing same Runtime exception.
System.loadLibrary("gnustl_shared.so");

Any idea what I am doing wrong here.

Thanks & Regards,
Vijayasarathy.M

David Turner

unread,
Jun 14, 2013, 11:21:52 AM6/14/13
to andro...@googlegroups.com
This should be:

  System.loadLibrary("gnustl_shared");

Otherwise the library won't be found.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Worner Bon

unread,
May 29, 2014, 6:27:38 AM5/29/14
to andro...@googlegroups.com
Hi All, 

I am using ndk to build my cpp files and I am also facing the issue related to RB Tree

Error:
error: undefined reference to 'std::_Rb_tree_increment(std::_Rb_tree_node_base*)'
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&)'

After a long R&D also I am not able to remove this error can any one help me on this, I am also presenting my Application.mk file here
home/worner/jni/Application.mk :-
APP_ABI := armeabi-v7a
APP_PLATFORM := android-14

APP_CPPFLAGS += -fexceptions -fpermissive
APP_CPPFLAGS += -DLib_ANDROID
#APP_MODULES := socketio_static

APP_BUILD_SCRIPT := $(NDK_PROJECT_PATH)/Android.mk
APP_STL:=gnustl_static

And /home/worner/Android.mk :-
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := TestMain

LOCAL_MODULE_FILENAME := libTestMain

LOCAL_CFLAGS := -DLib_ANDROID \
                -DLib_OS_ANDROID \
                -frtti \
                -std=gnu++11 \
                -fexceptions

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

LOCAL_SRC_FILES := main.cpp \
                   TestTarget.cpp \
                   TestEndpointTarget.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. \
                    /home/worner/GM/socket.lib/trunk/Foundation/include/ \
                    /home/worner/GM/socket.lib/Library/include/ \
                    /home/worner/GM/socket.lib/trunk/JSON/include/ \
                    /home/worner/GM/socket.lib/trunk/Net/include/ \
                    

LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \
                    /home/worner/GM/socket.lib/GMSocket-Lib/NetLib/Net/include/ \
                    /home/worner/GM/socket.lib/GMSocket-Lib/FoundationLib/Foundation/include/ \
                    /home/worner/GM/socket.lib/GMSocket-Lib/JSONLib/JSON/include/ \
                    /home/worner/GM/socket.lib/GMSocket-Lib/include/include/Library/ \
                    /home/worner/GM/socket.lib/GMSocket-Lib/include/ \
                    /home/worner/socket.lib/GMSocket-Lib/include/c++/4.6/arm-linux-androideabi/armv7-a/bits/ \
                    /home/worner/GM/socket.lib/GMSocket-Lib/header/include/c++/4.6/bits/
                   

LOCAL_LDLIBS :=  -L/home/worner/GM/socket.lib/lib/Android/armeabi-v7a \
                 -L/home/worner/GM/socket.lib/obj/local/armeabi-v7a \
                 -L/home/worner/GM/socket.lib/lib/armv7-a

LOCAL_LDLIBS += <Path of libgnustl_static.a>
LOCAL_LDLIBS += <Path of libsupc++.a >


LOCAL_LDLIBS +=  -lstdc++ \
                 -lLibraryFoundation \
                 -lLibraryNet \
                 -lLibraryXML \
                 -lLibraryJSON \
                 -lsocketioLibrary \
                 -lLibraryFoundationd \
                 -lLibraryNetd \
                 -lLibraryJSONd \
                 -lLibraryXMLd  \
                 -llog

include $(BUILD_EXECUTABLE)

Am I missing something to include in Android.mk file, Appreciate the help.

Worner.

David Turner

unread,
May 29, 2014, 8:47:05 AM5/29/14
to andro...@googlegroups.com
Please don't hijack existing thread, create new ones instead.


For more options, visit https://groups.google.com/d/optout.

Alex Cohn

unread,
Jul 14, 2014, 7:13:19 PM7/14/14
to andro...@googlegroups.com
You should not use gcc 4.6; use NDK_TOOLCHAIN_VERSION=4.8 or NDK_TOOLCHAIN_VERSION=clang in your Application.mk

Sincerely,
Alex Cohn
Reply all
Reply to author
Forward
0 new messages