<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