4

I have seen some Java projects using taucs.dll, TAUCS—a C library of sparse linear solvers, through JNI in Windows. I guess I can achieve the same in Mac OS X by compiling TAUCS into something like libTaucs.jnilib. I have access to the library's code but no idea how to compile it into a DLL, let alone a JNI library. So far I can compile only to a static library.

Is there a way to convert a DLL to a JNI library for Mac? If I have to compile the code, how to do so? Will wrapping a static library in a dynamic library work with JNI, especially for TAUCS if anyone has an experience?

puri
  • 807
  • 1
  • 11
  • 23

2 Answers2

8

Finally Microsoft released .NET Core which is completely platform independent. When you build a DLL using .NET Core framework you can run the file with following command.

dotnet yourapp.dll

Also, now .NET applications can be developed on Mac or Linux machine using the lightweight IDE Visual Studio Code and Visual Studio for Mac IDE has been released where Mono on MacOS X is integrated.

Shahdat
  • 5,094
  • 3
  • 36
  • 36
5

Many operating systems have the concept of shared libraries, but ofcourse the format etc. of such libraries is different on different operating systems.

DLLs (Dynamically Linked Libraries) are the Windows version of shared libraries. You cannot just use a DLL from a Windows machine on Mac OS, exactly like you cannot run a Windows application on Mac OS (or any other operating system).

Instead of trying to use a Windows DLL on Mac OS, you need to find a Mac OS-specific version of the native library that you are trying to use. Or if you have the source code, compile it into a Mac OS-native shared library. Shared libraries on Mac OS X have the extension .so (instead of .dll), which stands for "shared object".
Loading them using just Java is not possible.

Sumit Singh
  • 24,095
  • 8
  • 74
  • 100
  • Thanks for your answer. Actually I knew that but formed the question in this way because I secretly hoped that there would be a magic step to do so. By the way, Wine will be against the whole idea of making my heavy functions faster. – puri Oct 26 '11 at 19:16
  • In the interest of accuracy. Saying that it is not possible with Java is not accurate. Of course it is possible, it just is not easy and there are (AFAIK) ready made facilities for that. In principle all we need to do is to write code that can read .dll files and parse the entry points and then use for example JNA to call them via those entry points. An added complication is if the .dll makes calls to WinAPI (many/most will do) and that is where a Wine solution comes in. So possible, but not easy and very laborious. – nyholku Aug 17 '16 at 16:24
  • Also in the interest of accuracy using WINE is not necessarily slow. Setting up and starting WINE takes time but depending on how the .dll functions are called executing them could be fast. – nyholku Aug 17 '16 at 16:25