6

Upgrading to ndk 8b I receiving some crash report (most of them are Galaxy SII with Android 4.03)

java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1286]: 1836 cannot locate '__gnu_thumb1_case_uqi'...
at java.lang.Runtime.loadLibrary(Runtime.java:370)
at java.lang.System.loadLibrary(System.java:535)
at com.iuculano.fplayer.SDLActivity.void onCreate(android.os.Bundle)(SourceFile:324)
at android.app.Activity.performCreate(Activity.java:4465)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1993)
at android.app.ActivityThread.access$600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1159)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4507)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)

The exception is caused by a simple System.loadLibrary("main");

What does it mean? cannot locate '__gnu_thumb1_case_uqi'

Giuseppe
  • 2,093
  • 1
  • 21
  • 26
  • please run your ndk-build with V=1 and post the command line for link step – Alex Cohn Sep 02 '12 at 10:07
  • Have you had any problem with devices with OS != 4.0.3? – Supahfly May 15 '13 at 15:02
  • Hi, I am facing same issue, where i am loading SQLiteDatabase.loadLibs(this) and it throws me about exception. Which works fine in Android 4.2 and higher, but not working in HTC one V device having v4.0.3, please help!! – Zoombie Sep 16 '15 at 13:04

3 Answers3

6

The __gnu_thumb1_case_uqi is a helper which does an indexed jump on a densely packed switch table; quickly implements the switch. You have two options: avoid it or link with it.

If you increase an optimization level (by using -O3) you might not need this symbol. Also, changing the CPU may help as well as using thumb2 instructions. Compiling with the -ffreestanding option may also avoid this symbol. If you have control over the switch statement, you can replace it with an array of function pointers.

This routine is inside libgcc. You can statically link libgcc. Somewhere in the Android SDK/compiler, there must be a libgcc.a. Link with libgcc.a, using -L and -l or use -static-libgcc linker option to get the code (see http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html).

Edit: If you aren't compiling anything, then you can find libgcc.so on your system. It might be in /lib or /usr/lib or perhaps some place weird for Android devices. Adding the directory where the libgcc.so is located to the environment variable LD_LIBRARY_PATH could also fix the problem. It maybe unfortunate that Samsung released incompatible binaries and you have no way to fix the issue if you aren't compiling your own code. The correct libgcc.so maybe inside something like /usr/lib/thumb for multi-lib distributions. I don't know much about the Davlik stuff, but the Android JVM might not pointing to the right set of libraries when it runs.

andr
  • 15,970
  • 10
  • 45
  • 59
artless noise
  • 21,212
  • 6
  • 68
  • 105
  • This hasn't solved the problem for me yet, but it's good information nonetheless... – Nathan Monteleone Jan 10 '13 at 19:06
  • Unfortunately, NDK does not export `__gnu_thumb1_case_uqi` in any of its libraries. – Alex Cohn Mar 19 '14 at 15:50
  • NDK by itself is probably using 'bionic'; a google libc, so libgcc.so is probably not the issue, but some 'bionic' library version which doesn't include it, probably you would have to build with an older NDK to not have the symbol. I think the function will be the same in 'bionic' as glibc; a switch statement. – artless noise Oct 30 '15 at 18:17
2

Are you compiling for armv7? If you're not, try compiling for armv7.

Luca Carlon
  • 9,546
  • 13
  • 59
  • 91
  • I'm compiling also for armv7, and I really don't understand why you wrote about the Necessitas Qt Creator – Giuseppe Aug 31 '12 at 19:12
  • 1
    Because I made a mistake, sorry :-) I confused the question with another one in which Qt Creator was used. Anyway, I had the same exact issue when trying to load a library compiled for armv5 on a armv7 device. Compiling for armv5 made it work perfectly, so I didn't investigate further, but I thought it might help. – Luca Carlon Aug 31 '12 at 20:42
1

Producing optimised NDK code for multiple architectures?

read about 'arm' vs 'thumb' in the accepted answer in the above link.

then, remove your config instructions to build for thumb and verify that you are building for arm...

OR...

ill make a wild guess ... its the library order you have in the linker statement in your 'Android.mk'

try the google forum for ndk ... searching for 'cannot locate symbol'...

Really desperate?

see 'Runtime errors' section here

Community
  • 1
  • 1
Robert Rowntree
  • 6,230
  • 2
  • 24
  • 43