NDK r15c UnsatisfiedLinkError on symbol __errno_location

86 views
Skip to first unread message

jere...@iruleathome.com

unread,
Sep 1, 2017, 6:33:47 PM9/1/17
to android-ndk
Hello, I have a puzzling problem that I can't seem to nail down. We compile a shared library, with a few statically linked third party libraries -- and finally we statically link in -static-libstdc++

However, when I run the android app that uses this shared library, I get the following error:

09-01 13:15:13.284 29279-29279/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: <package name removed>, PID: 29279
                                                   java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__errno_location" referenced by "/data/app/<package name removed>/lib/arm64/libbrain_jni.so"...
                                                       at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
                                                       at java.lang.System.loadLibrary(System.java:1657)
                                                       at <package name removed>.ApplicationBridge.<clinit>(ApplicationBridge.java:10)
                                                       at <package name removed>.ApplicationBridge.getInstance(ApplicationBridge.java:78)
                                                       at <package name removed>.GlobalApplication.checkStartApplicationBridge(GlobalApplication.java:218)
                                                       at <package name removed>.GlobalApplication.onCreate(GlobalApplication.java:151)
                                                       at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1118)
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5791)
                                                       at android.app.ActivityThread.-wrap1(Unknown Source:0)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1661)
                                                       at android.os.Handler.dispatchMessage(Handler.java:105)
                                                       at android.os.Looper.loop(Looper.java:164)
                                                       at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
09-01 13:15:13.404 29279-29335/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default

Upon examining this library though...it seems like this symbol is there.
[mine@archshadow nexus5]$ adb pull "/data/app/<package name removed>/lib/arm64/libbrain_jni.so"
/data/app/<package name removed>/lib/arm64/libbrain_jni.so: 1 file pulled. 14.7 MB/s (24125512 bytes in 1.569s)
$ nm -D libbrain_jni.so | grep __errno_location
                 U __errno_location
$ ../android-toolchains/android-arm64/bin/aarch64-linux-android-nm -D libbrain_jni.so | grep "__errno_location"
                 U __errno_location



I'm thinking it might be a signature issue or something with __errno_location__, but I'm not sure what I should do to solve it.

I've used this to generate the toolchain:
${NDK_MAKE_TOOLCHAIN} --api=23 \
 --arch=arm64-v8a \
 --install-dir="${toolchain}" \
 --stl=libc++


and I'm on 
Linux archshadow 4.12.8-2-ARCH #1 SMP PREEMPT Fri Aug 18 14:08:02 UTC 2017 x86_64 GNU/Linux




Dan Albert

unread,
Sep 1, 2017, 6:56:54 PM9/1/17
to android-ndk, enh
It seems __errno_location doesn't exist in Android, it's just __errno. Presumably somewhere in your code you have an `extern int* __errno_location()` (which according to the doc, is what you're supposed to do)

@enh: looks like __errno_location is part of LSB? http://refspecs.linux-foundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/baselib---errno-location.html. Should we add it and do the usual __RENAME stuff for older API levels?

--
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/1bdc4a38-d6fa-43f1-acbb-f566959db358%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

enh

unread,
Sep 5, 2017, 1:56:04 PM9/5/17
to Dan Albert, android-ndk
meh, LSB is pretty meaningless. "we copy and paste whatever glibc
happens to be doing today".

given that _only_ glibc uses this i worry that it would make it harder
for people to realize they've screwed up by compiling against the
glibc headers and trying to run on Android. (which is the first
reference i find to __errno_location on stack overflow.)
>> email to android-ndk...@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/1bdc4a38-d6fa-43f1-acbb-f566959db358%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>



--
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

jere...@iruleathome.com

unread,
Sep 6, 2017, 1:22:09 PM9/6/17
to android-ndk
yeah, something with the way the toolchain is being used on my ArchLinux box apparently tries to link glibc or use its headers or something.

compiling the entire thing without changing anything on a Ubuntu 16.04 virtual box works fine, no UnsatisfiedLinkError, no __errno_location symbol present in the resulting shared library.

I'm not sure what's causing it, and I don't even have an idea
Reply all
Reply to author
Forward
0 new messages