Shared Library Load Path

3,696 views
Skip to first unread message

karl-heinz reichel

unread,
Aug 4, 2009, 1:51:28 PM8/4/09
to andro...@googlegroups.com
I have ported a larger shared library to android. 
Now I would like to test that lib with a small c++ application which loads that library.
For testing the shared lib I will use the adb to start that application.
But when I start the app I get the error message that the app cannot load the shared lib.
Investigating the app with strace shows that the app will load the shared lib from /system/lib.
As /system/lib is read only my question: Is there a way to force the loading of the shared lib from a different directory ? 

regards
karl-heinz


David Turner

unread,
Aug 4, 2009, 2:30:06 PM8/4/09
to andro...@googlegroups.com
This is not currently possible with Android 1.5. I believe the next system release will support LD_LIBRARY_PATH which will solve the issue.

Rohit Grover

unread,
Aug 4, 2009, 5:18:01 PM8/4/09
to andro...@googlegroups.com
It is possible to remount /system/lib as read-write. Refer to the man page of 'mount' for the relevant command line options.

karl-heinz reichel

unread,
Aug 5, 2009, 2:51:48 AM8/5/09
to andro...@googlegroups.com
sounds good, I will take a try for that 
thanks

2009/8/4 Rohit Grover <rgro...@gmail.com>

karl-heinz reichel

unread,
Aug 6, 2009, 5:48:00 AM8/6/09
to andro...@googlegroups.com

This approach won't work too.., as there is not enough space left in /system/lib.. (symbolic links seems not to be working... )
Maybe another approach:
Is it possible to implement the following scenario:
I create a small java app for android, this app references a NDK Build Shared Lib..
this shared lib references then my ported lib...
Is such a scenario possible with android 1.5 ?
best regards
karl-heinz
2009/8/5 karl-heinz reichel <khre...@googlemail.com>

David Turner

unread,
Aug 7, 2009, 5:00:45 AM8/7/09
to andro...@googlegroups.com
On Thu, Aug 6, 2009 at 11:48 AM, karl-heinz reichel <khre...@googlemail.com> wrote:

This approach won't work too.., as there is not enough space left in /system/lib.. (symbolic links seems not to be working... )
Maybe another approach:
Is it possible to implement the following scenario:
I create a small java app for android, this app references a NDK Build Shared Lib..
this shared lib references then my ported lib...
Is such a scenario possible with android 1.5 ?

This will not work, due to the exact same bug. For the dynamic linker, there is very little difference between an executable that wants to link to another shared library, and a shared library that wants to link to another one (they're all ELF executables after all)
 

Divkis

unread,
Mar 15, 2010, 11:30:34 PM3/15/10
to andro...@googlegroups.com
Hi,
I was going through older messages on this problem but couldn't
figure how to specify load libraries paths for a native application
which is dynamically linked to some of my shared libraries.

Since David Turner seem to suggests (see the email thread below) that
LD_LIBRARY_PATH should have been fixed in NDK_1.6 release, has it
already been fixed? If yes, then does simply setting LD_LIBRARY_PATH
with adb shell export LD_LIBRARY_PATH=<path-to-my-libs>:
$LD_LIBRARY_PATH, work? I am not sure how would one set the
LD_LIBRARY_PATH on Android.

If someone has been able to re mount /system/lib in a read write
location then could someone please let me know where it is being
remounted?

On a desktop linux system, one can mount any non read write mount to /
tmp (which has r/w permission by default) with mount --bind /from-
dir/ /tmp/ and then rebind it to the <from-dir> making it writable.

Any help is appreciated,
Thanks in advance,
Divkis

---------- Forwarded message ----------
From: David Turner <di...@android.com>
Date: Aug 4 2009, 11:30 pm
Subject: Shared Library Load Path
To: android-ndk


This is not currently possible with Android 1.5. I believe the next
system
release will support LD_LIBRARY_PATH which will solve the issue.

On Tue, Aug 4, 2009 at 7:51 PM, karl-heinz reichel

<khreic...@googlemail.com

Emmanuel

unread,
Mar 18, 2010, 12:32:22 PM3/18/10
to android-ndk
> This is not currently possible with Android 1.5. I believe the next
> system
> release will supportLD_LIBRARY_PATHwhich will solve the issue.

It worked for me in Android 2.1 (on the emulator).

But shouldn't it be also in 1.6 (Donut)? It didn't seem to work.
http://android.git.kernel.org/?p=platform%2Fbionic.git&a=search&h=HEAD&st=commit&s=LD_LIBRARY_PATH

Emmanuel

Emmanuel

unread,
Mar 25, 2010, 10:07:05 AM3/25/10
to android-ndk
In fact, it works in 1.6, even like this:
adb shell "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/data/local/tmp;
$path_to_exe_to_run"
(may it's be since I upgrade to Ndk r3?).


> But shouldn't it be also in 1.6 (Donut)? It didn't seem to work.http://android.git.kernel.org/?p=platform%2Fbionic.git&a=search&h=HEA...208

Reply all
Reply to author
Forward
0 new messages