-
class MyInterface virtual int Connect(LPCSTR server) =0; typedef int (*InterfaceVersion_t)(void); I'm new to JavaCPP and have managed to use it to generate the peer Java mapping classes for the header file of the win32 DLL, but I have no idea how to use JavaCPP to reference the address of the CreateInterface function on the win32 DLL and assign it to the C++ *CreateInterface function pointer variable for it to be invoked to create and return a reference to a MyInterface object instance. JavaCPP generated the peer Java FunctionPointer class of the C++ CreateInterface function pointer. The generated FunctionPointer class has a public native int call(int version, @cast(MyInterface*) PointerPointer my_interface) method for the C++ CreateInterface function pointer variable, but I'm not sure what to do from there to invoke the public native int call(int version, @cast(MyInterface*) PointerPointer my_interface) method such that a Java MyInterface object reference can be returned and accessed in its PointerPointer output variable. If someone can advise on how to get this working, I'd really appreciate it. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Your CreateInterface is just a typedef, it's not a variable or anything we
can actually call. You'll need to consult the API and figure out first how
to use it from C++.
|
Beta Was this translation helpful? Give feedback.
-
JavaCPP just wraps C++, so it can be done. If allocation fails it's most
likely unrelated to JavaCPP.
|
Beta Was this translation helpful? Give feedback.
I solved this problem by creating a C wrapper 64 bit DLL for the target Win 64 bit DLL variant of the Win 32 bit DLL. Then, I used the jextract tool to create Java FFM (Foreign Function and Memory) bindings that allowed me to interact with the target Win 64 bit DLL.
The limitation encountered when trying to directly interface with both target 32 bit and 64 bit DLLs was that 64 bit JVMs are now not supporting 32 bit DLLs and both DLLs are using __stdcall function call standard which is not supported by Java/Java FFM. Therefore, it was necessary to create the wrapper DLL which uses __cdecl function call standard which allowed Java to indirectly integrate with the target DLL.
Also, a C wrapp…