tags:

views:

334

answers:

1

I've got a .so library compiled for Linux under the ELF format, which is being used by a Java program. I'm trying to port this application to Mac OS X, and have discovered that OS X uses a different extension for these files, .jnilib. I've already figured out how to set up the PATH so that it correctly finds the files. However, OS X Java cannot load the .so files (because it expects the other extension).

If I change the file extension from .so to .jnilib, the JVM can find the files but can't read them (since they've been compiled incorrectly).

Is there any way, either in a Linux system or in Mac OS X, without the source code, to convert these .so files to .jnilib? I suspect that this is not possible, but Stack Overflow hasn't failed me yet - and I wouldn't count "it's not possible" as failure.

+1  A: 

Are you trying to use a native library for Linux on Mac OS X? No. That's not going to work.

You need get a Mac version of the native library and rename it to jnilib if it doesn't have that suffix already.

That's the main difference between JVM byte code and native code. Native code is very platform specific. We even have multiple versions of JNI libraries for different linux flavors.

Since Mac and Linux all uses the same CPU and they are all Unix-based, I wouldn't say it's impossible even though it's pretty close to that.

ZZ Coder
That's what I was afraid of. In response to your first question, yes, that's what I would like to do, and unfortunately, I can't get a Mac version of the native library - the company that makes it doesn't have a Mac version available.
Glen