Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a native windows DLL inside a Linux JVM

I've got an simple API with native functions(JNA) inside a DLL file which only calculates some mathematical stuff. I am using this DLL inside an JAVA application and everything works fine on the windows JVM.

The problem is that this library is going to be used in a Linux enviroment inside a Linux JVM and there will be no *.so version.

I read a couple of times that there is a way to load the DLL with wine inside the memory and use it from there but without explanations how to do it.

Can somebody confirm or refute this approach for me. And could tell me how to do it if this is really a possible sollution, please?

edit: Could be a solution which is described in How to call Wine dll from python on Linux? Can I somehow use ctypes?

Regards wurmi

like image 673
wurmi Avatar asked Oct 19 '22 00:10

wurmi


1 Answers

I think you should be able to do this, but I can't find a step-by-step guide, and I haven't done it myself. Try doing the following:

  • Create a linux C application which calls the native functions in your DLL, using winelib
    • See https://web.archive.org/web/20131229032547/http://wine-wiki.org/index.php/WineLib#Calling_a_Native_Windows_dll_from_Linux
    • See https://stackoverflow.com/a/720073/8261
  • Once that is working in C, export a function from that C code which delegates through to the DLL and compile it up as a so (a linux DLL)
  • Invoke your C so from JNA on linux

Good luck!

Hopefully someone who has done this before will provide a more detailed answer here. If not, be sure to post how to do it as an answer so that others can benefit :-)

(The answer you linked to is referring to Windows-provided DLLs, and Wine ships with so-compiled versions of those.)

like image 94
Rich Avatar answered Oct 22 '22 02:10

Rich