How to properly link to shared library in the NDK

223 views
Skip to first unread message

Gabi Zuniga

unread,
Nov 29, 2016, 10:53:41 AM11/29/16
to android-ndk
I am trying to access a shared library from the NDK code and I am getting a run time error, not able to find the library.
I tried both cmake and ndk-build (following this https://developer.android.com/ndk/guides/prebuilts.html) without success.

java.lang.UnsatisfiedLinkError: dlopen failed: library "./obj/local/arm64-v8a/libstellite.so" not found
                                                     at java.lang.Runtime.loadLibrary0(Runtime.java:977)

It seems like the library is expected to be in a particular location and is not there.
I was able to load the library manually with System.loadLibrary() however the implicit load was still failing.

Is there a way to force the implicit load to look in the library path?

Dan Albert

unread,
Nov 29, 2016, 5:35:20 PM11/29/16
to android-ndk
I'm not sure what implicit loading you're referring to. Do you mean you're calling `System.loadLibrary` on some other library that depends on libstellite.so? If that's the case, it looks like you're missing an SONAME entry for libstellite (as in the library wasn't built with `-soname libstellite.so` in it's ldflags; ndk-build does this automatically, but I can't speak for all the other options).

java.lang.UnsatisfiedLinkError: dlopen failed: library "./obj/local/arm64-v8a/libstellite.so" not found

Hmm. That's not the path it should have. Should be "libs/arm64-v8a/libstellite.so" iirc. Certainly not obj. This is certainly a system of a missing SONAME.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/ed06fd1f-599b-4fee-b5c2-196fe0cf536d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages