2 messages in net.java.dev.jna.usersRe: [jna-users] Another UnsatisfiedLi...
FromSent OnAttachments
Timothy WallNov 26, 2007 3:29 pm 
Geoffrey ArnoldNov 26, 2007 5:03 pm 
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:Re: [jna-users] Another UnsatisfiedLinkErrorActions...
From:Geoffrey Arnold (geof@geoffreyarnold.com)
Date:Nov 26, 2007 5:03:28 pm
List:net.java.dev.jna.users

Thanks Tim, that worked (for the current distribution)!

However, I'm now trying to deploy on Solaris, so I grabbed the latest jna.jar from the jnalib-v3 branch (what happened to Native::synchronizedLibrary?!) and I'm back to the same error. Please note, I have not actually attempted to run on Solaris yet; I have only upgraded the jna.jar and am attempting to run the same test which previously succeeded on Windows:

java.lang.UnsatisfiedLinkError: Cannot locate function '_fooBar' at com.sun.jna.NativeLibrary.getFunctionAddress(NativeLibrary.java:187) at com.sun.jna.Function.<init>(Function.java:112) at com.sun.jna.Function.<init>(Function.java:154) at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:175) at com.sun.jna.Library$Handler.invoke(Library.java:145) at $Proxy0._fooBar(Unknown Source)

Geoff.

On Nov 26, 2007 6:29 PM, Timothy Wall <twal@dev.java.net> wrote:

On Nov 26, 2007, at 5:33 PM, Geoffrey Arnold wrote:

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 ...

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'

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

_fooBar@12

You w32 version of the library is using the stdcall calling convention, so on that platform you will need to use a StdCallFunctionMapper (as a library option) to properly map the function names, and you will also need to derive from StdCallLibrary to get the right calling convention (or your VM will crash).

An easy way to do this is to define the basic interface, then derive a w32 interface from that which includes the StdCall interface. Then use one or the other depending on the current platform.