Hello everybody,
I have a little problem while trying to use JNA with my own DLL.
I defined the function :
int add(int a, int b)
I tried many mappings (StdCallLibrary, Library, etc ...), for instance:
public interface DllFunction extends StdCallLibrary {
DllFunction INSTANCE = (DllFunction)Native.loadLibrary("DllTest",
DllFunction.class);
public int add(int a, int b);
}
but every time, the call:
DllFunction.INSTANCE.add(12, 30)
raises an "java.lang.UnsatisfiedLinkError: Cannot locate function 'add'".
I tried also to pass an StdCallFunctionMapper but it fixed nothing.
After taking a look at the dll file with depends i found that the function
was named "?add@@YAHHH@Z", and thus:
NativeLibrary nl = NativeLibrary.getInstance("DllTest");
Function f = nl.getFunction("?add@@YAHHH@Z");
Object[] a = {12,30};
System.out.println(f.invokeInt( a ));
works fine.
I wonder if there is a way to do it the "right" way ie with the interface
mapping ?
Thank you for any help !
Nicolas