3 messages in net.java.dev.jna.usersAnother UnsatisfiedLinkError
FromSent OnAttachments
Geoffrey ArnoldNov 26, 2007 2:33 pm 
Timothy WallNov 26, 2007 5:14 pm 
Geoffrey ArnoldNov 27, 2007 6:39 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Another UnsatisfiedLinkErrorActions...
From:Geoffrey Arnold (geof@geoffreyarnold.com)
Date:Nov 26, 2007 2:33:16 pm
List:net.java.dev.jna.users

I love the promise of JNA, however I am stuck trying to integrate it into our first project. We have a third party library (no source available) compiled for Windows and Solaris containing a "fooBar" method (names changed to protect the innocent). The documentation for the method contains the following signature:

int fooBar(char *param1, char *param2, char *param3)

Callers are required to provide param1 and param2; the function then populates param3 with a value (right now I am uninterested in the value of "param3" after the method call so I am not using a Pointer). The return value is a code which indicates whether the function was successful.

I am trying to use JNA to invoke this function:

public interface FooBarLibrary extends Library {

int fooBar(String param1, String param2, String param3);

}

String param1 = "aParam"; String param2 = "anotherParam"; String param3 = ""; // NOTE: not using a Pointer

FooBarLibrary library = (FooBarLibrary) Native.loadLibrary("FooBar", FooBarLibrary.class); instance.fooBar(param1, param2, param3);

...and am receiving the following error:

java.lang.UnsatisfiedLinkError: Cannot locate function 'fooBar' at com.sun.jna.NativeLibrary.getFunctionAddress(NativeLibrary.java:228) at com.sun.jna.Function.<init>(Function.java:143) at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:212) at com.sun.jna.Library$Handler.invoke(Library.java:165) at $Proxy0.fooBar(Unknown Source) ...

I fired up Dependency Walker and the library contains the following method export:

_fooBar@12

...so I attempted to change the method name in the FooBarLibrary interface to include the leading underscore (ie. "_fooBar") but still no luck.

Any help would be greatly appreciated.

Thanks, Geoff.