Can't find library

1,601 views
Skip to first unread message

Roger Cruz

unread,
Nov 24, 2011, 1:36:20 AM11/24/11
to andro...@googlegroups.com
I have compiled Wine with the NDK and when I try to execute it in the emulator, I get the following error
 
# ./wine
link_image[1962]:   303 could not load needed library 'libwine.so.1' for './wine' (load_library[1104]: Library 'libwine.so.1' not found)CANNOT LINK EXECUTABLE
 
I dumped the headers for the wine executable and I can see the library paths are specified as relative to the location of the wine executable.  The needed libraries are indeed one level up and down in the 'lib' directory
 
Dynamic section at offset 0x92c contains 28 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libwine.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so]
 0x00000001 (NEEDED)                     Shared library: [libdl.so]
 0x0000000f (RPATH)                      Library rpath: [$ORIGIN/../lib]
 0x0000001d (RUNPATH)                    Library runpath: [$ORIGIN/../lib]
 
So I'm stipulating that the linker in Android does not support the relative path and an absolute path must be specified.  Is this correct?  Is there a way to tell force the $ORIGIN to be honored?
 
Thanks in advanced,
 
Roger R. Cruz

Marco Bernasocchi

unread,
Nov 24, 2011, 5:31:59 AM11/24/11
to andro...@googlegroups.com, Roger Cruz
is the lib in the actually in the apk?
ciao

Tor Lillqvist

unread,
Nov 24, 2011, 5:43:42 AM11/24/11
to andro...@googlegroups.com, Roger Cruz
> So I'm stipulating that the linker in Android does not support the relative path and an absolute path must be specified.
> Is this correct? Is there a way to tell force the $ORIGIN to be honored?

Grep the sources for the Bionic dynamic linker (bionic/linker in an Android source tree checkout), you will not see any "RPATH" or "ORIGIN". GNU is not Unix, and Android is not GNU/Linux;) See another recent thread titled "loading library with dependencies", although that is about normal Android apps packaged in .apk files; you are apparently building an executable and running it straight from the adb shell, so you can presumably set LD_LIBRARY_PATH etc.

(Interesting idea to port Wine to Android (Android on x86, presumably), what use case do you see for that? Or actually, yeah, I can see how that could be useful, some ultraportable running Android as its OS, and then running also Windows apps through Wine.)

--tml



Tor Lillqvist

unread,
Nov 24, 2011, 5:50:17 AM11/24/11
to andro...@googlegroups.com, Roger Cruz
is the lib in the actually in the apk?

What apk? He seems to have built a "normal" Linux executable program, not an app.
 
android does not support versioned libs.

The term "versioned libs" sounds a bit scary, if what you really mean is just "dynamic shared object file with a name like libfoo.so.42". It's the app package creation and installation code that is strict and doesn't like native libs not conforming to the libfoo.so convention. This doesn't affect what the original poster is doing, I think, as no app seems to be involved. As far as I can see, the Bionic dynamic linker as such doesn't care what the names of dynamic shares object files are like.
 
--tml

David Turner

unread,
Nov 24, 2011, 5:56:43 AM11/24/11
to andro...@googlegroups.com
The Android dynamic linker doesn't support rpath/runpath at all. You can however set LD_LIBRARY_PATH before launching your executable (since you're not starting an Android application process, which uses fork() and thus cannot see any changes to this variable).

That's exactly the technique used by the NDK test suite when it runs its executables on a device, it first copies the programs and libraries to /data/local/ndk-tests then does something like:

adb shell LD_LIBRARY_PATH=/data/local/ndk-tests /data/local/ndk-tests/<program-name>

Regarding support for versioned libraries, you probably can load them from a stand-alone executable. What is not supported is the ability to automatically package them when building an .apk, and automatically installing them into /data/data/<package-name>/lib at installation time. You can however load them manually if you know their full path.

Keep in mind that standalone executable programs are not Android applications, the system can see the corresponding processes and decide to kill them at any time to reclaim memory, for example, so be prepared for them to disappear any time.
 
Thanks in advanced,
 
Roger R. Cruz

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
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.

Roger Cruz

unread,
Nov 24, 2011, 10:48:52 AM11/24/11
to andro...@googlegroups.com
Thank you all for the very insightful answers.  I am using 'adb push' to get the executables to the emulator.. no apk at the moment.  Using LD_LIBRARY_PATH did the trick and it did load the versioned library.
 
Roger 
Reply all
Reply to author
Forward
0 new messages