Hello,
I am trying to wrap a set of native (C) libraries using JNA and am running into issues I do not understand.
I converted the following C header:
extern _ADLL_DECL_SPEC void RDBMS_Init (void);
extern _ADLL_DECL_SPEC void RDBMS_Shut (void);
extern _ADLL_DECL_SPEC RDBMS_MXFUNCTION *RDBMS_pFctGet (void);
using jnaerator to the following java code
public interface RdbmsStdLibrary extends Library {
String JNA_LIBRARY_NAME = "rdbms_std";
NativeLibrary JNA_NATIVE_LIB = NativeLibrary.getInstance(RdbmsStdLibrary.JNA_LIBRARY_NAME);
RdbmsStdLibrary INSTANCE = (RdbmsStdLibrary) Native.loadLibrary(RdbmsStdLibrary.JNA_LIBRARY_NAME, RdbmsStdLibrary.class);
void RDBMS_Init();
void RDBMS_Shut();
RdbmsStdLibrary.RDBMS_MXFUNCTION RDBMS_pFctGet();
public static class RDBMS_MXFUNCTION extends PointerType {
public RDBMS_MXFUNCTION() {
super();
}
public RDBMS_MXFUNCTION(Pointer address) {
super(address);
}
}
}
Then I wrote a simple unit test to try my stuff
private static final File BASEDIR = new File(System.getProperty("basedir", ".")).getAbsoluteFile();
@BeforeClass
public static void setUp() throws Exception {
System.setProperty("jna.library.path",new File(BASEDIR,"src/test/resources/rdbms").getAbsolutePath());
}
@Test
public void invokeNativeMethodWhenCallingFunctionOnInstance() throws Exception {
RdbmsStdLibrary std = RdbmsStdLibrary.INSTANCE;
std.RDBMS_Init();
std.RDBMS_Shut();
}
And I got the following stack trace:
java.lang.UnsatisfiedLinkError: Error looking up function 'RDBMS_Init': La procédure spécifiée est introuvable.
at com.sun.jna.Function.<init>(Function.java:179)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:350)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:330)
at com.sun.jna.Library$Handler.invoke(Library.java:203)
at $Proxy6.RDBMS_Init(Unknown Source)
This is really frustrating as it does not seem to be possible to have a simpler function.
I am running this on windows7, DLLs are compiled in 32bits and test is run with a 32bit JVM (1.6.0_06 FWIW), I am running jna 3.4.0. I checked the dll's export table and everything appears to be there.
What am I doing wrong ?
Thanks
Arnaud