Android下没有ldd可以使用,在进行ndk开发的时候,检查库的依赖项特别麻烦。有两个解决方案:1、将linux的的ldd移植过去。因为android也是基于linux的,所以将ldd移植过去是完全可能的,google一下吧,这不是本文的重点;2、现成的。ndk已经提供了工具,在ubuntu下执行locatereadelf,你会发现有这些输出:/mydroid/external/elfutils/src/readelf.c/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-readelf/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.2.1/man/man1/arm-eabi-readelf.1/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.3.1/bin/arm-eabi-readelf/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.3.1/man/man1/arm-eabi-readelf.1/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-readelf/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.4.0/man/man1/arm-eabi-readelf.1/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-readelf/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/man/man1/arm-eabi-readelf.1/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin/arm-eabi-readelf/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/man/man1/arm-eabi-readelf.1/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-readelf/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/man/man1/arm-eabi-readelf.1/mydroid/prebuilt/linux-x86/toolchain/i686-unknown-linux-gnu-4.2.1/bin/i686-unknown-linux-gnu-readelf/mydroid/prebuilt/linux-x86/toolchain/i686-unknown-linux-gnu-4.2.1/man/man1/i686-unknown-linux-gnu-readelf.1/mydroid/prebuilt/linux-x86/toolchain/sh-4.3.3/bin/sh-linux-gnu-readelf/usr/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-readelf/usr/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-readelf/usr/bin/readelf/usr/share/man/man1/readelf.1.gz加粗的部分就是你可以使用的工具了。测试一下:当你完成android的编译后,测试如下:root@dylan-ubuntu:/mydroid/out/target/product/generic/system/bin#/usr/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-readelf-dtest_pvauthorengineDynamicsectionatoffset0x20b00contains26entries:TagTypeName/Value0x00000001(NEEDED)Sharedlibrary:[libopencore_author.so]0x00000001(NEEDED)Sharedlibrary:[libopencore_common.so]0x00000001(NEEDED)Sharedlibrary:[libdl.so]0x00000001(NEEDED)Sharedlibrary:[libc.so]0x00000001(NEEDED)Sharedlibrary:[libstdc++.so]0x00000001(NEEDED)Sharedlibrary:[libm.so]0x00000020(PREINIT_ARRAY)0x280000x00000021(PREINIT_ARRAYSZ)0x80x00000019(INIT_ARRAY)0x280080x0000001b(INIT_ARRAYSZ)8(bytes)0x0000001a(FINI_ARRAY)0x280100x0000001c(FINI_ARRAYSZ)8(bytes)0x00000004(HASH)0x81080x00000005(STRTAB)0x8fb00x00000006(SYMTAB)0x85a00x0000000a(STRSZ)4570(bytes)0x0000000b(SYMENT)16(bytes)0x00000015(DEBUG)0x00x00000003(PLTGOT)0x28bf80x00000002(PLTRELSZ)1144(bytes)0x00000014(PLTREL)REL0x00000017(JMPREL)0xa19c0x00000011(REL)0xa18c0x00000012(RELSZ)16(bytes)0x00000013(RELENT)8(bytes)0x00000000(NULL)0x0root@dylan-ubuntu:/mydroid/out/target/product/generic/obj/lib#/usr/android/android-ndk-r4b/build/prebuilt/linux-x86/arm-eabi-4.2.1/bin/arm-eabi-readelf-dlibopencore_common.soDynamicsectionatoffset0xcc448contains36entries:TagTypeName/Value0x00000001(NEEDED)Sharedlibrary:[libutils.so]0x00000001(NEEDED)Sharedlibrary:[libcutils.so]0x00000001(NEEDED)Sharedlibrary:[libui.so]0x00000001(NEEDED)Sharedlibrary:[libhardware.so]0x00000001(NEEDED)Sharedlibrary:[libandroid_runtime.so]0x00000001(NEEDED)Sharedlibrary:[libdrm1.so]0x00000001(NEEDED)Sharedlibrary:[libmedia.so]0x00000001(NEEDED)Sharedlibrary:[libskia.so]0x00000001(NEEDED)Sharedlibrary:[libvorbisidec.so]0x00000001(NEEDED)Sharedlibrary:[libsonivox.so]0x00000001(NEEDED)Sharedlibrary:[liblog.so]0x00000001(NEEDED)Sharedlibrary:[libicuuc.so]0x00000001(NEEDED)Sharedlibrary:[libcamera_client.so]0x00000001(NEEDED)Sharedlibrary:[libsurfaceflinger_client.so]0x00000001(NEEDED)Sharedlibrary:[libdl.so]0x00000001(NEEDED)Sharedlibrary:[libc.so]0x00000001(NEEDED)Sharedlibrary:[libstdc++.so]0x00000001(NEEDED)Sharedlibrary:[libm.so]0x0000000e(SONAME)Librarysoname:[libopencore_common.so]0x00000010(SYMBOLIC)0x00x00000019(INIT_ARRAY)0xc70000x0000001b(INIT_ARRAYSZ)16(bytes)0x00000004(HASH)0xb40x00000005(STRTAB)0xc6fc0x00000006(SYMTAB)0x420c0x0000000a(STRSZ)86133(bytes)0x0000000b(SYMENT)16(bytes)0x00000003(PLTGOT)0xcc5880x00000002(PLTRELSZ)1032(bytes)0x00000014(PLTREL)REL0x00000017(JMPREL)0x221440x00000011(REL)0x217740x00000012(RELSZ)2512(bytes)0x00000013(RELENT)8(bytes)0x6ffffffa(RELCOUNT)40120x00000000(NULL)0x0转载把libnids-1.20/src/killtcp.c 的倒数第2,3行删掉或注释掉即可。
//#elif
//#error Something wrong with LIBNET_VER
您好,java端
调用libNLPIR.so我们这边使用的JNA的方式调用您要是按照我们下面的例子代码调用的
CLibrary
Instance
=
(CLibrary)
Native.loadLibrary(
"E:\java\JNI\jnaTest\NLPIR",
CLibrary.class)出现了上诉问题的话,建议您使用下面的命令查看一下您调用的库是否有问题先:ldd
libNLPIR.so
看看石油有调用的权限,如果没有权限的话,您可以在linux命令行执行:
chmod
+x
libNLPIR.soexport
LD_LIBRARY_PATH=[directory]
这个目录是您的libNLPIR.so动态库的目录JNA异常java.lang.UnsatisfiedLinkError:
Unable
to
load
library处理方法通常我们都会建议用上诉方法解决,如果您按照上诉方法仍然无法解决的话,您要是不介意您可以贴一下您的调用实例,我们这边定位一下问题。感谢您支持大数据论坛
评论列表(0条)