Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top