Off topic: asking for some advice, since this loader sounds close to what I want. The problem: I need to use a huge C++ codebase that is developed on the Mac, and is used to generate a shared library used in a Java app with JNI, SWIG, and loaded with loadLibrary. It would be fantastic to be able to build a shared library on the Mac, and be able to use it on both Macs and Linux servers. Maintaining and building 2 versions is a nuisance. (A complete build takes a couple of hours, even on a fast box.) Probably not possible because shared libraries are very different on OS X and Linux, but long term it would save me a lot of time if it is, even if I had to patch the Linux JVM.
This loader will be buggy and incomplete, by it's nature, and won't really solve the problems inherent in loading a shared library from another OS into an existing native process.
Thanks for the response! It was a long shot, but I thought that I would ask in case someone new of a stable and reliable way to use OS X shared libraries on Linux. I imagine it would be easier on NetBSD.
Not really. The problem is the binary format itself - Linux, *BSD, and pretty much every Unix but AIX these days uses ELF, but OSX uses MachO. The two aren't compatible.
The easiest way to do this reliably would probably involve writing your own mini-linker load the Mach-O binaries in Linux from the JVM, bypassing dlopen() and friends.