280
技術社區[雲棲]
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'
1、你自己寫的函數,那麼你應該去檢查自己所寫的這段代碼有何問題,修改之後,再重新編譯底層庫;
2、係統函數,暫時還沒找到合適的解決辦法,正在努力尋求方法。
最後更新:2017-04-02 06:51:50