K
K
kicum2013-03-29 11:55:53
linux
kicum, 2013-03-29 11:55:53

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)

wrapper.dll - a wrapper left over from the previous programmer, there is outdated code, there is a working version only under win32
target.dll - a library supplied by partners, no code, but there are versions of the library for all platforms.

The problem is this: How to move to Linux with this zoo? And is it possible to cut wrapper.dll

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kicum, 2013-03-29
@kicum

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!

I
igor_suhorukov, 2013-04-02
@igor_suhorukov

code.google.com/p/bridj/

B
barker, 2013-03-29
@barker

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 question

Ask a Question

731 491 924 answers to any question