Answer the question
In order to leave comments, you need to log in
How to connect Java and C++ in extreme conditions?
The situation is this: there is Java code that calls code from a library (dll) written in C ++, the link now looks like this:
Java - > wrapper.dll(Win32) -> target.dll(Win32)
Answer the question
In order to leave comments, you need to log in
In such a situation, I got the following, step by step:
1. We take target.dll and decompile it, as a result we get target.h - a file.
2. We take target.so for Linux and decompile it in the same way, as a result we get target-linux.h - a file.
3. Compare them (I was lucky and they are more or less the same in terms of function signatures and constants).
4. We feed this utility here - JNAerator , it gives us Java code to call using the JNA framework
5. Refactor the constructed Java code and work with it (I got that the functions in the generated code are slightly different in name)
6. We write a decorator for the previous implementation.
That's it!
It is very difficult to move with such a zoo to Linux in the general case.
About cutting wrapper.dll is not very clear. Obviously, this is a JNI lib that is already pulling some left target.dll. Calling directly in your case is almost impossible.
Instead of wrapper.dll, I wrote a console utility that pulls target.dll, and communicated with it via stdin / stdout. I could not come up with a more non-gemoral solution.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question