阅读280 返回首页    go 阿里云 go 技术社区[云栖]


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

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

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

static{  
	try{
		System.load("/data/data/com.***/lib/lib***.so");
	}  
	catch(UnsatisfiedLinkError ulink){ 
		Log.i("HVnative====","Can not load library");
		ulink.printStackTrace();
	}
}


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

snowdream@snowdream:~/workspace/$ arm-none-linux-gnueabi-ld lib***.so
arm-none-linux-gnueabi-ld: warning: libc.so, needed by lib***.so, not found (try using -rpath or -rpath-link)
arm-none-linux-gnueabi-ld: warning: libdvm.so, needed by lib***.so, not found (try using -rpath or -rpath-link)
lib***.so: warning: the use of `tmpnam' is dangerous, better use `mkstemp'
arm-none-linux-gnueabi-ld: warning: cannot find entry symbol _start; defaulting to 00008248
lib***.so: undefined reference to `__aeabi_fadd'
lib***.so: undefined reference to `__aeabi_fdiv'
lib***.so: undefined reference to `__aeabi_fcmpge'
lib***.so: undefined reference to `__aeabi_dcmpgt'
lib***.so: undefined reference to `__aeabi_dcmpeq'
lib***.so: undefined reference to `__aeabi_uidiv'
lib***.so: undefined reference to `__aeabi_ui2d'
lib***.so: undefined reference to `__aeabi_dcmple'
lib***.so: undefined reference to `__aeabi_fcmplt'
lib***.so: undefined reference to `__aeabi_i2d'
lib***.so: undefined reference to `__aeabi_uidivmod'
lib***.so: undefined reference to `__aeabi_fmul'
lib***.so: undefined reference to `__aeabi_d2uiz'
lib***.so: undefined reference to `__aeabi_fcmpeq'
lib***.so: undefined reference to `__aeabi_d2iz'
lib***.so: undefined reference to `__aeabi_dcmpge'
lib***.so: undefined reference to `__aeabi_ldivmod'
lib***.so: undefined reference to `__aeabi_d2f'
lib***.so: undefined reference to `__aeabi_dmul'
lib***.so: undefined reference to `__aeabi_dcmplt'
lib***.so: undefined reference to `__aeabi_f2d'
lib***.so: undefined reference to `__aeabi_fcmple'
lib***.so: undefined reference to `__aeabi_idivmod'
lib***.so: undefined reference to `__aeabi_fsub'
lib***.so: undefined reference to `__aeabi_ddiv'
lib***.so: undefined reference to `__aeabi_ui2f'
lib***.so: undefined reference to `__aeabi_i2f'
lib***.so: undefined reference to `__aeabi_idiv'
lib***.so: undefined reference to `__aeabi_dadd'
lib***.so: undefined reference to `__aeabi_fcmpgt'
lib***.so: undefined reference to `__aeabi_dsub'
lib***.so: undefined reference to `__aeabi_f2iz'


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

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


最后更新:2017-04-02 06:51:50

  上一篇:go setLatestEventInfo
  下一篇:go 一些小算法