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:Timothy Wall (twal@dev.java.net)
Date:Nov 26, 2007 3:29:03 pm
List:net.java.dev.jna.users

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.