我有那些java文件:
// i2cjni.java
public class i2cJNI {
static {
try {
System.loadLibrary("i2cbrdg");
}
catch(UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
}
}
public final static native long U2C_GetDeviceCount();
public final static native long U2C_OpenDevice(long jarg1);
public final static native long U2C_CloseDevice(long jarg1);
...
}
// i2c.java
public class i2c {
public static SWIGTYPE_p_BYTE U2C_GetDeviceCount() {
return new SWIGTYPE_p_BYTE(i2cJNI.U2C_GetDeviceCount(), true);
}
// I2CBoard.java
public class I2CBoard extends i2c{
public static void main(String[] args) {
SWIGTYPE_p_BYTE nDevice = new SWIGTYPE_p_BYTE();
i2c.U2C_OpenDevice(nDevice);
SWIGTYPE_p_BYTE mDevice = i2c.U2C_GetDeviceCount();
System.out.println("mDevice: " + mDevice);
}
}
- 我已经设置了这样的本机库路径:
i2c_wrapper/Native library location: ro.i2c.mirela/os/x86_64
and in the same way to the rest of them: JRE System Library, Plug-in Dependencies, ro.i2c.mirela/os(class folder) and i2c_wrapper
- 我已将此文件夹添加到项目中:
os/x86_64/i2c_wrapper.dll
os/x86_64/i2cbrdg.dll
os/x86_64/U2CCommon.dll
- 当我尝试调用U2C_GetDeviceCount()函数等时,我收到此错误。有任何想法吗?
Exception in thread "main" java.lang.UnsatisfiedLinkError: ro.i2c.mirela.board.i2cJNI.U2C_OpenDevice(J)J
at ro.i2c.mirela.board.i2cJNI.U2C_OpenDevice(Native Method)
at ro.i2c.mirela.board.i2c.U2C_OpenDevice(i2c.java:28)
at ro.i2c.mirela.board.I2CBoard.main(I2CBoard.java:8)
答案 0 :(得分:0)
就像是一个链接错误,可能是你的.c文件函数名称不对,也许你应该发布你的.c 档案