ndk - clang - java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__tls_get_addr" referenced by "libHDRLib.so"...

1,414 views
Skip to first unread message

Kris

unread,
Jul 10, 2014, 7:58:38 AM7/10/14
to andro...@googlegroups.com
Hi,

I am trying to switch to clang 3.4 using latest NDK to build my library when I get this error while app is launching. 

07-10 17:08:58.433: E/dalvikvm(16527): dlopen("/data/app-lib/com.alpha.hdr.hdrtest-2/libHDRLib.so") failed: dlopen failed: cannot locate symbol "__tls_get_addr" referenced by "libHDRLib.so"...

07-10 17:08:58.433: W/dalvikvm(16527): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/alpha/hdr/HDRTestActivity;
07-10 17:08:58.433: W/dalvikvm(16527): Class init failed in newInstance call (Lcom/alpha/hdr/HDRTestActivity;)
07-10 17:08:58.433: W/dalvikvm(16527): threadid=1: thread exiting with uncaught exception (group=0x415eeba8)
07-10 17:08:58.433: E/AndroidRuntime(16527): FATAL EXCEPTION: main
07-10 17:08:58.433: E/AndroidRuntime(16527): Process: com.alpha.hdr.hdrtest, PID: 16527
07-10 17:08:58.433: E/AndroidRuntime(16527): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__tls_get_addr" referenced by "libHDRLib.so"...
07-10 17:08:58.433: E/AndroidRuntime(16527): at java.lang.Runtime.loadLibrary(Runtime.java:364)
07-10 17:08:58.433: E/AndroidRuntime(16527): at java.lang.System.loadLibrary(System.java:526)
07-10 17:08:58.433: E/AndroidRuntime(16527): at com.alpha.hdr.HDRTestActivity.<clinit>(HDRTestActivity.java:96)
07-10 17:08:58.433: E/AndroidRuntime(16527): at java.lang.Class.newInstanceImpl(Native Method)
07-10 17:08:58.433: E/AndroidRuntime(16527): at java.lang.Class.newInstance(Class.java:1208)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.app.ActivityThread.access$800(ActivityThread.java:135)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.os.Handler.dispatchMessage(Handler.java:102)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.os.Looper.loop(Looper.java:136)
07-10 17:08:58.433: E/AndroidRuntime(16527): at android.app.ActivityThread.main(ActivityThread.java:5001)
07-10 17:08:58.433: E/AndroidRuntime(16527): at java.lang.reflect.Method.invokeNative(Native Method)
07-10 17:08:58.433: E/AndroidRuntime(16527): at java.lang.reflect.Method.invoke(Method.java:515)
07-10 17:08:58.433: E/AndroidRuntime(16527): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
07-10 17:08:58.433: E/AndroidRuntime(16527): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
07-10 17:08:58.433: E/AndroidRuntime(16527): at dalvik.system.NativeStart.main(Native Method)

Do i need to link to some additional library to satisfy this error or do i need to build my static library with some flags. My library is compiling and linking fine but shows this error at runtime.

Thanks in advance

Martin Rajniak

unread,
Oct 28, 2014, 12:23:25 PM10/28/14
to andro...@googlegroups.com
I am having the same issue - dlopen failed: cannot locate symbol "__tls_get_addr" referenced by ...

I am building with NDK-r10c on 64-bit Windows. 
Project's target platform is Android-21.
Library was built and tested for arm-v7a architectures (nameley Nexus 4, Samsung Galaxy Note 3).
As mentioned, I am also using CLang (latest version 3.5). Same codebase is working alright with GCC 4.8 & GCC 4.9.

Could anyone share some thoughts about this?

Thanks

Scott Dixon

unread,
Oct 1, 2015, 2:54:49 PM10/1/15
to android-ndk
__tls_get_addr is used by linux to get the address of a thread_local. Are you using thread local variables? Sorry if this isn't a solution but it might help you isolate the problem.

Dan Albert

unread,
Oct 2, 2015, 9:56:41 AM10/2/15
to android-ndk
Android does not natively support the ELF style TLS. GCC gets this on Android by emulating TLS calls with pthread_(get|set)specific. Clang 3.4 did not support that, but the next one released in the NDK should (which will be a 3.8svn release).

Until then, you're unfortunately stuck with writing the pthread calls yourself or using GCC.
Reply all
Reply to author
Forward
0 new messages