Android Jni调用so库 加载库失败分析


现有一个项目,通过JNI接口调用底层库,例如:lib***.so

如下所示,总是加载不成功。调试发现,每次加载so库,会跳到catch异常处理部分,然后打印异常log信息。

  1. static{    
  2.     try{  
  3.         System.load("/data/data/com.***/lib/lib***.so");  
  4.     }    
  5.     catch(UnsatisfiedLinkError ulink){   
  6.         Log.i("HVnative====","Can not load library");  
  7.         ulink.printStackTrace();  
  8.     }  
  9. }  

arm-none-linux-gnueabi-ld工具发现有些函数未定义,如下所示:

  1. snowdream@snowdream:~/workspace/$ arm-none-linux-gnueabi-ld lib***.so  
  2. arm-none-linux-gnueabi-ld: warning: libc.so, needed by lib***.so, not found (try using -rpath or -rpath-link)  
  3. arm-none-linux-gnueabi-ld: warning: libdvm.so, needed by lib***.so, not found (try using -rpath or -rpath-link)  
  4. lib***.so: warning: the use of `tmpnam' is dangerous, better use `mkstemp'  
  5. arm-none-linux-gnueabi-ld: warning: cannot find entry symbol _start; defaulting to 00008248  
  6. lib***.so: undefined reference to `__aeabi_fadd'  
  7. lib***.so: undefined reference to `__aeabi_fdiv'  
  8. lib***.so: undefined reference to `__aeabi_fcmpge'  
  9. lib***.so: undefined reference to `__aeabi_dcmpgt'  
  10. lib***.so: undefined reference to `__aeabi_dcmpeq'  
  11. lib***.so: undefined reference to `__aeabi_uidiv'  
  12. lib***.so: undefined reference to `__aeabi_ui2d'  
  13. lib***.so: undefined reference to `__aeabi_dcmple'  
  14. lib***.so: undefined reference to `__aeabi_fcmplt'  
  15. lib***.so: undefined reference to `__aeabi_i2d'  
  16. lib***.so: undefined reference to `__aeabi_uidivmod'  
  17. lib***.so: undefined reference to `__aeabi_fmul'  
  18. lib***.so: undefined reference to `__aeabi_d2uiz'  
  19. lib***.so: undefined reference to `__aeabi_fcmpeq'  
  20. lib***.so: undefined reference to `__aeabi_d2iz'  
  21. lib***.so: undefined reference to `__aeabi_dcmpge'  
  22. lib***.so: undefined reference to `__aeabi_ldivmod'  
  23. lib***.so: undefined reference to `__aeabi_d2f'  
  24. lib***.so: undefined reference to `__aeabi_dmul'  
  25. lib***.so: undefined reference to `__aeabi_dcmplt'  
  26. lib***.so: undefined reference to `__aeabi_f2d'  
  27. lib***.so: undefined reference to `__aeabi_fcmple'  
  28. lib***.so: undefined reference to `__aeabi_idivmod'  
  29. lib***.so: undefined reference to `__aeabi_fsub'  
  30. lib***.so: undefined reference to `__aeabi_ddiv'  
  31. lib***.so: undefined reference to `__aeabi_ui2f'  
  32. lib***.so: undefined reference to `__aeabi_i2f'  
  33. lib***.so: undefined reference to `__aeabi_idiv'  
  34. lib***.so: undefined reference to `__aeabi_dadd'  
  35. lib***.so: undefined reference to `__aeabi_fcmpgt'  
  36. lib***.so: undefined reference to `__aeabi_dsub'  
  37. lib***.so: undefined reference to `__aeabi_f2iz'  

如果“undefined reference to” 后面打印的函数是:
1、你自己写的函数,那么你应该去检查自己所写的这段代码有何问题,修改之后,再重新编译底层库;

2、系统函数,暂时还没找到合适的解决办法,正在努力寻求方法。

相关内容