Can't find libdl

1,234 views
Skip to first unread message

death_jester

unread,
Jul 12, 2012, 7:15:09 AM7/12/12
to android-ndk
Hi Developers,
I have a very strange problem. I'm using a library which uses the
libdl to call the function dladdr. Now everytime I try to build my
application using this library it complains about

undefined reference to `dladdr'
collect2: ld returned 1 exit status

In my Android.mk file I added the line

LOCAL_LDLIBS :=-ldl

But it still can't find this function. I even tried to give the path
to the library with '-L'. And I checked the library file with "arm-
linux-androideabi-readelf -s -D -W libdl.so" to check if the library
really contains this functions. It does!

In my Application.mk I have only one line:

APP_STL:=gnustl_static

Can somebody help me or explain to me what I can do to find the
problem?

Cheers,
Jester

Thomas Martitz

unread,
Jul 12, 2012, 7:19:33 AM7/12/12
to andro...@googlegroups.com
dladdr() is a non-POSIX GNU extension found in glibc (see [1]). You
probably don't find it in android because it's not using glibc but the
bionic C library.

[1]: http://linux.die.net/man/3/dladdr

Chris Stratton

unread,
Jul 12, 2012, 7:47:00 AM7/12/12
to android-ndk
On Jul 12, 7:19 am, Thomas Martitz <thomas.mart...@student.htw-
berlin.de> wrote:
> dladdr() is a non-POSIX GNU extension found in glibc (see [1]). You
> probably don't find it in android because it's not using glibc but the
> bionic C library.

It is in the bionic sources, and apparently .so (though that is fake
as the actual runtime implementations are in /system/bin/linker)

Chris Stratton

unread,
Jul 12, 2012, 8:09:54 AM7/12/12
to android-ndk
On Jul 12, 7:15 am, death_jester <d3ath.jes...@googlemail.com> wrote:
> undefined reference to `dladdr'
>
> In my Android.mk file I added the line
>
> LOCAL_LDLIBS :=-ldl
>
> But it still can't find this function. I even tried to give the path
> to the library with '-L'. And I checked the library file with "arm-
> linux-androideabi-readelf -s -D -W libdl.so" to check if the library
> really contains this functions. It does!

Did you check the library from the same platform version you compiled
against? Just experimenting with this, I don't see it in android-3
or android-4, but do see it from android-8.

Pass the V=1 flag to ndk-build to see what platform's lib directory it
is actually linking against.
Try it with target=android-8 in default.properties of the main app
directory.

death_jester

unread,
Jul 12, 2012, 8:12:45 AM7/12/12
to andro...@googlegroups.com
Ok, thanks for the reply, but I'm not quiet sure how this helps me. So you say that Androids libc does contain the dladdr function, and it should work?

death_jester

unread,
Jul 12, 2012, 8:23:12 AM7/12/12
to andro...@googlegroups.com
Thank you I think this is really the problem. Because 'ndk-build' uses the libld.so from android-3 and there is no dladdr() function in it. But I though when I give it the full path to the library (with -L) it would work.

How can I define a newer Android version for ndk-build?

Thank you for your help Chris!

Mārtiņš Možeiko

unread,
Jul 12, 2012, 3:42:03 PM7/12/12
to andro...@googlegroups.com
You can do that with by putting "APP_PLATFORM := android-8" in
Application.mk file.

--
Mārtiņš Možeiko
> --
> You received this message because you are subscribed to the Google Groups
> "android-ndk" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/android-ndk/-/QraCzU2l9ukJ.
>
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to
> android-ndk...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/android-ndk?hl=en.
Reply all
Reply to author
Forward
0 new messages