首页 > 解决方案 > Android NDK 链接共享库

问题描述

我目前正在尝试将 3 个预构建的共享库链接到本机 JNI 共享库。共享库是在 linux 上构建的。当我将其中一个库链接到本机 JNI 时,我收到了一个不令人满意的链接错误,附在下面。

  Loading the library normally failed: java.lang.UnsatisfiedLinkError: dlopen failed: library "libc.so.6" not found. 

我的共享库(libdivsufsort)的运行时依赖关系如下所示

Dynamic section at offset 0x9e00 contains 25 entries:
Tag        Type                         Name/Value
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
0x000000000000000e (SONAME)             Library soname [libdivsufsort.so.3]
0x000000000000000c (INIT)               0x8b8
0x000000000000000d (FINI)               0x85c8
0x0000000000000019 (INIT_ARRAY)         0x209de8
0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
0x000000000000001a (FINI_ARRAY)         0x209df0
0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
0x000000006ffffef5 (GNU_HASH)           0x1f0
0x0000000000000005 (STRTAB)             0x510
0x0000000000000006 (SYMTAB)             0x258
0x000000000000000a (STRSZ)              375 (bytes)
0x000000000000000b (SYMENT)             24 (bytes)
0x0000000000000003 (PLTGOT)             0x20a000
0x0000000000000002 (PLTRELSZ)           216 (bytes)
0x0000000000000014 (PLTREL)             RELA
0x0000000000000017 (JMPREL)             0x7e0
0x0000000000000007 (RELA)               0x708
0x0000000000000008 (RELASZ)             216 (bytes)
0x0000000000000009 (RELAENT)            24 (bytes)
0x000000006ffffffe (VERNEED)            0x6c8
0x000000006fffffff (VERNEEDNUM)         1
0x000000006ffffff0 (VERSYM)             0x688
0x000000006ffffff9 (RELACOUNT)          3
0x0000000000000000 (NULL)               0x0

我的其他图书馆也出现了类似的问题。该链接在 linux 上运行良好,因为 libc.so.6 在库路径中。android 似乎不支持与版本库的动态链接,也不在 system/lib 中包含版本库。我该如何解决这个问题?

标签: android-ndkdynamic-linking

解决方案


推荐阅读