我使用android ndk独立工具链成功地将 c ++库编译成了android平台。 我使用jni dolder和Android.mk文件在Eclipse中创建了一个新的Android应用程序项目,当我进行ndk-build时,构建顺利,并将mylib.so添加到libs / armeabi文件夹 问题是当我做一个System.loadLibrary(“mylibname”); 我在logcat中收到以下错误: 无法dlopen(/data/data/com.oussama.firsttry/lib/libdash.so):无法加载库:link_image [1995]:无法链接libdash.so 导致 java.lang.UnsatisfiedLinkError:我的lib未找到** 。
我的lib必须有一个库,模拟器无法加载它所以我已经完成了 readelf -d mylib.so ,结果如下:
偏移量为0x1617c4的动态部分包含26个条目:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x0000000e (SONAME) Library soname: [libdash.so]
0x00000010 (SYMBOLIC) 0x0
0x0000000f (RPATH) Library rpath: [/home/oussama064/libdash/libdash/../../neededLibs]
0x00000019 (INIT_ARRAY) 0x157268
0x0000001b (INIT_ARRAYSZ) 172 (bytes)
0x0000001a (FINI_ARRAY) 0x157314
0x0000001c (FINI_ARRAYSZ) 8 (bytes)
0x00000004 (HASH) 0xf4
0x00000005 (STRTAB) 0x10f58
0x00000006 (SYMTAB) 0x50b8
0x0000000a (STRSZ) 134112 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000003 (PLTGOT) 0x1618b4
0x00000002 (PLTRELSZ) 1096 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x40dd8
0x00000011 (REL) 0x31b38
0x00000012 (RELSZ) 62112 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x00000018 (BIND_NOW)
0x6ffffffb (FLAGS_1) Flags: NOW
0x6ffffffa (RELCOUNT) 7738
0x00000000 (NULL) 0x0
这是我的Android.mk文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) LOCAL_MODULE := libcurl LOCAL_SRC_FILES :=
../../../../neededLibs/libcurl.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS) LOCAL_MODULE := libxml LOCAL_SRC_FILES :=
../../../../neededLibs/libxml2.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS) LOCAL_MODULE := libz LOCAL_SRC_FILES :=
../../../../neededLibs/libz.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS) LOCAL_MODULE := m LOCAL_SRC_FILES :=
libm.so include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS)
LOCAL_MODULE := dl LOCAL_SRC_FILES := libdl.so
include $(PREBUILT_SHARED_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE
:= c LOCAL_SRC_FILES := libc.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := d LOCAL_SRC_FILES := libdash.so
LOCAL_SHARED_LIBRARIES := c m dl
LOCAL_STATIC_LIBRARIES := libz libxml libcurl include
$(PREBUILT_SHARED_LIBRARY)
我现在真的陷入困境,我无法弄清楚丢失的库是什么
当我执行ndk-build V = 1 -B时,我得到以下结果:
rm -f /home/oussama064/Android/workspace/FirstTry/libs/armeabi/lib*.so
/home/oussama064/Android/workspace/FirstTry/libs/armeabi-v7a/lib*.so
/home/oussama064/Android/workspace/FirstTry/libs/mips/lib*.so
/home/oussama064/Android/workspace/FirstTry/libs/x86/lib*.so
rm -f / home / oussama064 / Android / workspace / FirstTry / libs / armeabi / gdbserver
/家庭/ oussama064 /安卓/工作区/ FirstTry /库/ armeabi-V7A / gdbserver的
/家庭/ oussama064 /安卓/工作区/ FirstTry /库/ MIPS / gdbserver的
/家庭/ oussama064 /安卓/工作区/ FirstTry /库/ 86 / gdbserver的
rm -f /home/oussama064/Android/workspace/FirstTry/libs/armeabi/gdb.setup
/home/oussama064/Android/workspace/FirstTry/libs/armeabi-v7a/gdb.setup
/home/oussama064/Android/workspace/FirstTry/libs/mips/gdb.setup
/home/oussama064/Android/workspace/FirstTry/libs/x86/gdb.setup
make:循环obj / local / armeabi / libm.so< - obj / local / armeabi / libm.so依赖
下降。
make:循环obj / local / armeabi / libm.so< - obj / local / armeabi / libc.so依赖
下降。
make:循环obj / local / armeabi / libdl.so< - obj / local / armeabi / libm.so依赖
下降。
make:循环obj / local / armeabi / libdl.so< - obj / local / armeabi / libc.so依赖
下降。
make:循环obj / local / armeabi / libdl.so< - obj / local / armeabi / libdl.so依赖
下降。
预建:libdl.so< = / home / oussama064 / Android / workspace / FirstTry / jni /
cp -f /home/oussama064/Android/workspace/FirstTry/jni/libdl.so
OBJ /本地/ armeabi / libdl.so
预建:libm.so< = / home / oussama064 / Android / workspace / FirstTry / jni /
cp -f /home/oussama064/Android/workspace/FirstTry/jni/libm.so obj / local / armeabi / libm.so
make:循环obj / local / armeabi / libc.so< - obj / local / armeabi / libc.so依赖项已丢弃。
预建:libc.so< = / home / oussama064 / Android / workspace / FirstTry / jni /
cp -f /home/oussama064/Android/workspace/FirstTry/jni/libc.so obj / local / armeabi / libc.so
安装:libc.so =>
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libc.so
安装-p ./obj/local/armeabi/libc.so
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libc.so
/家庭/ oussama064 / NDK / Android的NDK-R 8d中/工具链/ ARM-Linux的androideabi-
4.6 / prebuilt / linux-x86 / bin / arm-linux-androideabi-strip --strip-unneeded
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libc.so
预建:libxml2.a< =
/home/oussama064/Android/workspace/FirstTry/jni/../../../../neededLibs/
cp -f
/home/oussama064/Android/workspace/FirstTry/jni/../../../../neededLibs/libxml2.a
OBJ /本地/ armeabi / libxml2.a
预建:libcurl.a< =
/home/oussama064/Android/workspace/FirstTry/jni/../../../../neededLibs/
cp -f
/home/oussama064/Android/workspace/FirstTry/jni/../../../../neededLibs/libcurl.a
OBJ /本地/ armeabi / libcurl.a
预建:libdash.so< = / home / oussama064 / Android / workspace / FirstTry / jni /
cp -f /home/oussama064/Android/workspace/FirstTry/jni/libdash.so
obj/local/armeabi/libdash.so
Install : libdash.so =>
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libdash.so
install -p ./obj/local/armeabi/libdash.so
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libdash.so
/home/oussama064/NDK/android-ndk-r8d/toolchains/arm-linux-androideabi-
4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libdash.so
Install : libdl.so =>
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libdl.so
install -p ./obj/local/armeabi/libdl.so
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libdl.so
/家庭/ oussama064 / NDK / Android的NDK-R 8d中/工具链/ ARM-Linux的androideabi-
4.6 / prebuilt / linux-x86 / bin / arm-linux-androideabi-strip --strip-unneeded
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libdl.so
Install : libm.so =>
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libm.so
install -p ./obj/local/armeabi/libm.so
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libm.so
/home/oussama064/NDK/android-ndk-r8d/toolchains/arm-linux-androideabi-
4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-strip --strip-unneeded
/home/oussama064/Android/workspace/FirstTry/libs/armeabi/libm.so
如果有人能帮助我,我会感激不尽。