Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with other library JNI libc++_shared.so which is from different NDK version #1284

Open
zhlinh opened this issue Jun 19, 2024 · 2 comments

Comments

@zhlinh
Copy link

zhlinh commented Jun 19, 2024

When import mars-xlog and other library with libc++_shared.so, it encountered with the crash on launch that:

dlopen failed: cannot locate symbol "__emutls_get_address" referenced by
 "/data/app/~~9F9bkWmsoCf0Zx7jUEQu2A==/com.tencent.xriver.debug-I19tY0VOUbMwJzdk9fuJKw==/lib/arm64/libotherlib.so"...

Search the problem, noticed that it's because the mars-xlog use the ndk r20 to build and include the libc++_shared.so with r20 toolchain, which is different with other lib with r25c toolchain.

1. Info

1.1 With the help of parse_elfnote.py
mars-xlog: libc++_shared.so

$ parse_elfnote.py libc++_shared.so
----------ABI INFO----------
ABI_ANDROID_API: 21
ABI_NDK_VERSION: r20
ABI_NDK_BUILD_NUMBER: 5594570

other-lib: libc++_shared.so

$ parse_elfnote.py libc++_shared.so
----------ABI INFO----------
ABI_ANDROID_API: 21
ABI_NDK_VERSION: r25c
ABI_NDK_BUILD_NUMBER: 9519653

1.2 See the __emutls_get_address symbol with readelf
mars-xlog: libc++_shared.so

$ readelf -s libc++_shared.so | grep __emutls_get_address
Nothing

other-lib: libc++_shared.so

$ readelf -s libc++_shared.so | grep __emutls_get_address
   374: 00000000000ec5bc   448 FUNC    WEAK   DEFAULT   16 __emutls_get_address

So, the problem is the libc++_shared.so on r25c has __emutls_get_address weak symbol, but libc++_shared.so on r20 doesn't.

2. Try To Resolve

Choose libc++_shared.so on r25c will solve this problem, it can be compatitable with the so created by r20 toolchain.

  1. Try to use pickFirst **/libc++_shared.so on gradle packagingOptions. Unfortunately, not working

Not working, becasause it can not be sure choose which so, sometimes choose r25c, it's OK, but sometimes not.

3. Hope

the MARS TEAM

  1. can update the toolchain with r25c or above
  2. or SEPARATED libc++_shared.so on a independent project as mars dependence, apply different version to choose, like
com.tencent.mars:mars-xlog:1.2.5
  - com.tencent.mars:mars-c++_shared:20.0.5594570

then can offer diffrent version of c++shared to choose
- com.tencent.mars:mars-c++_shared:25.2.9519653
  1. or provide another STL way of c++_static (embed std in so), using the static version, and not export any symbol of c++_static. the maven project name can be different
com.tencent.mars:mars-xlog-stdembed:1.2.5
@wenideveloper
Copy link

这个问题解决了吗,我也遇到了这个冲突问题,引用了Xlog ,又引用了一个其他三方库,就报这个libc++_shared.so冲突
image

@zhlinh
Copy link
Author

zhlinh commented Jun 21, 2024

@wenideveloper have you tried adding pickFirst **/libc++_shared.so in the Gradle packagingOptions?

If your libc++_shared.so is the same NDK version, pickFirst will work.

@zhlinh zhlinh changed the title Conflict with other library JNI libc++_shared.so Conflict with other library JNI libc++_shared.so export from different NDK version Jun 21, 2024
@zhlinh zhlinh changed the title Conflict with other library JNI libc++_shared.so export from different NDK version Conflict with other library JNI libc++_shared.so which is from different NDK version Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants