9 messages in net.java.dev.jna.usersRe: [jna-users] Re: UnsatisfiedLinkE...
FromSent OnAttachments
Nicolas VienneDec 12, 2007 2:48 am 
Timothy WallDec 12, 2007 4:42 am 
Nicolas VienneDec 12, 2007 5:31 am 
Timothy WallDec 12, 2007 6:10 am 
Nicolas VienneDec 12, 2007 7:02 am 
Timothy WallDec 12, 2007 7:29 am 
Timothy WallDec 12, 2007 7:55 am 
Nicolas VienneDec 12, 2007 8:12 am 
Timothy WallDec 12, 2007 8:30 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:Re: [jna-users] Re: UnsatisfiedLinkError withActions...
From:Timothy Wall (twal@dev.java.net)
Date:Dec 12, 2007 6:10:21 am
List:net.java.dev.jna.users

On Dec 12, 2007, at 8:31 AM, Nicolas Vienne wrote:

Timothy Wall <twalljava@...> writes:

You have two options.

1) pass a StdCallFunctionMapper to Native.loadLibrary as an option. This will convert "add" to "add <at> 8", which is the default symbol generated for your add function with the stdcall convention.

2) tell your compiler/linker to generate undecorated symbols. With gcc, this is "-Wl,--add-stdcall-alias".

Oops, this gcc option tells gcc to *add* decorated symbols. If you leave it off, you get only undecorated symbols. MSVC requires you to futz with a DEF file to get undecorated symbols.

In addition, make sure you have extern "C" int add(int, int); ^^^^^^^^^^

as the function declaration if compiling with a C++ compiler. Otherwise the compiler mangles the name to include type information, and JNA does not automatically handle that.

Ok, I've done what you said. The symbol i actually have in the DLL is "_add@8". I tried (again) to use StdCallFunctionMapper but it doesn't work :( Map hm = new HashMap<String, Object>(); hm.put(DllFunction.OPTION_FUNCTION_MAPPER, new StdCallFunctionMapper()); DllFunction myDll = (DllFunction) Native.loadLibrary("DllTest", DllFunction.class, hm); System.out.println(myDll.add(12,30));

[The same result is obtained with DllFunction.FUNCTION_MAPPER and my interface extends StdCallInterface]

1. What is wrong in my use of the function mapper ? 2. Will it work (I'm optimistic) with function whose symbol ends with @12 or @20 ?

1. That should work, and does work within JNA's own unit tests (see W32StdCallTest). Make sure you're doing a clean build. 2. Yes, it will work with any function callable from JNA