2015年2月12日 星期四

eclipse 執行 native code 發生 Exception in thread "main" java.lang.UnsatisfiedLinkError: no libXXX in java.library.path 的錯誤訊息

這是JAVA找不到*.so檔
一般是使用System.loadLibrary("libXXX") 來載入lib但是在我的環境會發生" Exception in thread "main" java.lang.UnsatisfiedLinkError: no libXXX in java.library.path" 的錯誤訊息
1.設定Java Build Path->Source->Native library location選so檔放的路徑也無效
2.設定Java Build Path->Libraries->Native library location選so檔放的路徑也是無效
PS:System.loadLibrary("libXXX") 會到 java.library.path 所指明的檔案夾去載入適當的 native library。
再來使用System.load(String)函數來嘗試
1.設定好 eclipse JAVA Build Path
2.在程式碼中使用System.load(System.getProperty(java.class.path)+"/"+libXXX.so);

ps:System.load(String) 則可以從指定 local file system 上的某個檔案來載入。

沒有留言:

張貼留言