如何解决因为主数是库依赖项的一部分,所以无法加载共享库
| 我一直在创建一组共享库以在Android手机上运行。当我尝试将它们装入时,它们失败了,在我看来,共享库所依赖的库已经用它们的主编号命名了。 我应该解释说,我不使用ndk- *命令,而是使用具有通常配置脚本的ndk工具链。 作为一个简单的示例,尽管我的其他库也都这样做。我已经建立了libtiff与libjpeg的依赖关系。如果我对libtiff做一个readelf,我会明白这一点。$ /c/android/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/windows/bin/arm-eabi-readelf.exe -d libs/armeabi/libtiff.so
Dynamic section at offset 0x79988 contains 25 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libjpeg.so.8]
0x00000001 (NEEDED) Shared library: [libz.so]
0x00000001 (NEEDED) Shared library: [libm.so]
0x00000001 (NEEDED) Shared library: [libc.so]
0x00000001 (NEEDED) Shared library: [libdl.so]
0x0000000e (SONAME) Library soname: [libtiff.so.3]
0x00000010 (SYMBOLIC) 0x0
0x0000000f (RPATH) Library rpath: [c:/Users/whadden/workspace/jni_debug/jpeg-8c/.libs:C:/MinGW/ms
s/1.0/local/lib]
0x00000004 (HASH) 0xb4
0x00000005 (STRTAB) 0x1f54
0x00000006 (SYMTAB) 0xa24
0x0000000a (STRSZ) 5195 (bytes)
0x0000000b (SYMENT) 16 (bytes)
0x00000003 (PLTGOT) 0x7aa70
0x00000002 (PLTRELSZ) 768 (bytes)
0x00000014 (PLTREL) REL
0x00000017 (JMPREL) 0x4110
0x00000011 (REL) 0x3668
0x00000012 (RELSZ) 2728 (bytes)
0x00000013 (RELENT) 8 (bytes)
0x6ffffffe (VERNEED) 0x3648
0x6fffffff (VERNEEDNUM) 1
0x6ffffff0 (VERSYM) 0x33a0
0x6ffffffa (RELCOUNT) 339
0x00000000 (NULL) 0x0
如您所见,我本来希望看到名为libjpeg.so而不是libjpeg.so.8的libjpeg。由于这正被部署到Android手机,因此我不认为我可以创建符号链接来解决此问题,而且我也不认为我应该这样做。
当我尝试通过与手机的系统库进行测试链接来根源导致问题时,我得到
$ /cygdrive/c/android/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/window
s/bin/arm-eabi-ld libtiff.so -rpath=.
C:\\android\\android-ndk-r5b\\toolchains\\arm-eabi-4.4.0\\prebuilt\\windows\\bin\\arm-eabi-ld.exe: warning: libjpeg.so.8,needed
by libtiff.so,not found (try using -rpath or -rpath-link)
C:\\android\\android-ndk-r5b\\toolchains\\arm-eabi-4.4.0\\prebuilt\\windows\\bin\\arm-eabi-ld.exe: warning: cannot find entry sy
mbol _start; defaulting to 00008260
libtiff.so: undefined reference to `__aeabi_ui2f@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_CreateCompress@LIBJPEG_8.0\'
libtiff.so: undefined reference to `__aeabi_i2f@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_std_error@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_write_raw_data@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_set_defaults@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_finish_decompress@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_set_colorspace@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_suppress_tables@LIBJPEG_8.0\'
libtiff.so: undefined reference to `__aeabi_fdiv@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_read_header@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_write_tables@LIBJPEG_8.0\'
libtiff.so: undefined reference to `__aeabi_fsub@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_abort@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_set_quality@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_read_scanlines@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_resync_to_restart@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_destroy@LIBJPEG_8.0\'
libtiff.so: undefined reference to `__aeabi_f2iz@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_start_decompress@LIBJPEG_8.0\'
libtiff.so: undefined reference to `__aeabi_fadd@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_start_compress@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_write_scanlines@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_read_raw_data@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_CreateDecompress@LIBJPEG_8.0\'
libtiff.so: undefined reference to `__aeabi_fmul@LIBJPEG_8.0\'
libtiff.so: undefined reference to `jpeg_finish_compress@LIBJPEG_8.0\'
这表示未找到libjpeg,但是如果我将libjpeg重命名为libjpeg.so.8,则不会收到这些错误。
那我应该
a)修复构建,以使共享库中没有引用的主编号,更重要的是,我该怎么做?
b)用文件系统上的主要编号命名构建库? (我认为这是错误的)
/编辑
.o使用的命令行示例是
libtool: compile: arm-linux-androideabi-gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I/c/Users/whadden/workspace/jni/jpeg-8c -I/c/Users/whadden/workspace/jni/tiff-3.9.5/libtiff -O3 -mandroid -nostdlib -I/c/Users/whadden/workspace/jni/jpeg-8c -I/c/Users/whadden/workspace/jni/tiff-3.9.5/libtiff -Wall -W -MT tif_getimage.lo -MD -MP -MF .deps/tif_getimage.Tpo -c tif_getimage.c -fPIC -DPIC -o .libs/tif_getimage.o
顺便说一句,我刚搬到新的NDK R6
谢谢
会
解决方法
我应该解释说,我不使用ndk- *命令,而是使用具有通常配置脚本的ndk工具链。
尽管您的配置脚本正在生成一些使用ndk编译器的脚本,但实际上它是为从开发计算机环境中自动检测到的某些属性而构建的,例如libjpeg.so.8可能是正确的。
您可能需要修复configure脚本或手动编辑makefile,甚至可以使用sed来完成。
, 最后,我找到了一个解释我自己的问题的链接,它看起来像是android的限制。静态链接我们来了
http://comments.gmane.org/gmane.comp.handhelds.android.ndk/11819
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。