Android載入動態庫失敗分析

來源:互聯網
上載者:User

最近在做Android上的多媒體開發,通過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工具分析這個動態庫,在ubuntu 10.04上安裝arm-none-linux-gnueabi-gcc

方法參考文檔:

http://blog.csdn.net/satiling/article/details/6914466

找到 arm-none-linux-gnueabi-ld執行程式,添加到系統內容變數:

1.vim /root/.bashrc

2.PATH=$PATH:絕對路徑

3.source  /root/.bashrc 使環境變數立即生效,分析工具搞定!

如果“undefined reference to” 後面列印的函數是:

1、你自己寫的函數,那麼你應該去檢查自己所寫的這段代碼有何問題,修改之後,再重新編譯底層庫;

2、系統函數,暫時還沒找到合適的解決辦法,自己上網度狗吧,正在努力尋求方法。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.