9 messages in net.java.dev.jna.usersRe: C++ StdCallFunctionMapper
FromSent OnAttachments
Ewan SlaterApr 8, 2008 10:45 am 
Timothy WallApr 8, 2008 11:15 am 
Paul MooreApr 8, 2008 11:50 am 
Albert StrasheimApr 8, 2008 1:26 pm 
Ewan SlaterApr 9, 2008 12:44 am 
Timothy WallApr 9, 2008 3:53 am 
Ewan SlaterApr 9, 2008 11:44 am 
Timothy WallApr 9, 2008 7:32 pm 
Timothy WallApr 9, 2008 7:32 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: C++ StdCallFunctionMapperActions...
From:Ewan Slater (ewan@googlemail.com)
Date:Apr 9, 2008 12:44:23 am
List:net.java.dev.jna.users

<quote>

if they are plain functions (as opposed to class methods) you can put extern "C" in front of the fucntion declarations inthe c++ code and that will turn the name mangling off

</quote>

Tried that...and the level of mangling definitely comes down.

In my dll (using the dependency tool) I used to get...

?fnAmosMoses@@YGHXZ

...(mapping the mangled name directly worked just fine) and now I get...

_fnAmosMoses@0

which I hoped would work with the StdCallFunctionMapper.

But I still get UnsatisfiedLinkError!

So, am I doing something daft (code follows)?

calling code:

public static void main(String[] args) {

HashMap optionMap = new HashMap(); StdCallFunctionMapper mapper = new StdCallFunctionMapper(); optionMap.put(Library.OPTION_FUNCTION_MAPPER, mapper); //optionMap.put("fnAmosMoses","?fnAmosMoses@@YGHXZ"); //from dependency tool AmosMosesLib amos = (AmosMosesLib) Native.loadLibrary("AmosMoses", AmosMosesLib.class, optionMap); int amosSays = amos.fnAmosMoses(); System.out.println("Amos says " + amosSays);

}

interface: public interface AmosMosesLib extends Library { int fnAmosMoses(); double doubleD(double d); }

Declaring code #define AMOSMOSES_API __declspec(dllexport) extern "C" AMOSMOSES_API int fnAmosMoses(); extern "C" AMOSMOSES_API double doubleD(double d);

Cheers,

Ewan