Hi List.
I'm a very beginner on JNA :)
I would like to start test it as soon as possible and I have a really simple
question for you.
I have the following C code:
typedef void *MyDriverH; //Handle Type
MyDriverH __declspec(dllexport) __stdcall getDriverByIndex(int driverIndex);
What I have to do to get a Driver Handler in Java? I'm trying this solution
public interface MyDLL extends StdCallLibrary{
MyDLL INSTANCE = (MyDLL) Native.loadLibrary("MyDLL", MyDLL.class, new
HashMap() {{ put(OPTION_FUNCTION_MAPPER, FUNCTION_MAPPER); }});
public static class MyDriverH extends HANDLE {
}
public MyDriverH getDriverByIndex(int driverIndex);
public static class HANDLE extends PointerType {
public HANDLE() {
}
public HANDLE(Pointer p) {
super(p);
}
};
}
Then using this test code:
public class Test {
public static void main(String[]args){
MyDLL lib = MyDLL .INSTANCE;
MyDriverH driver = lib.getDriverByIndex(1);
}
}
But I receive this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot locate
function 'getDriverByIndex'
at com.sun.jna.NativeLibrary.getFunctionAddress(NativeLibrary.java:219)
at com.sun.jna.Function.<init>(Function.java:141)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:206)
at com.sun.jna.Library$Handler.invoke(Library.java:161)
at $Proxy0.getDriverByIndex(Unknown Source)
at attempt.Test.main(Test.java:9)
Surelly, I'm doing something wrong but I cant figure out what :)
Can someone help me?
Thanks
Dany