Subject: AIX and JNI: *.so versus *.a

From: "Daniel Richard G." <[email-masked]>
Date: Wed, 17 Aug 2011 17:58:26 -0400

Hello,

I am using Libtool 2.4 to build Java JNI modules on AIX.

I've noticed that on AIX, a shared library is initially built as an .so
file via "gcc -shared", but then this .so is packed up into an .a file
using ar(1). This is the case even if -export-dynamic -module is
specified.

When I go to use these JNI modules, however, the JRE makes very clear
that it doesn't like .a files:

Exception in thread "main" java.lang.UnsatisfiedLinkError: jni_test (    0509-022 Cannot load module /tmp/jni/libjni_test.a.
        0509-103   The module has an invalid magic number.)
        at java.lang.ClassLoader.loadLibraryWithPath(ClassLoader.java:994)
        at java.lang.ClassLoader.loadLibraryWithClassLoader(ClassLoader.java:958)
        at java.lang.System.loadLibrary(System.java:453)
        at com.example.jnitest.JniTest.<clinit>(JniTest.java:21)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:196)
        at JniTest.main(JniTest.java:56)

If I extract the .so files from the .a files, however, the JRE happily
uses those. Currently, I am using an install-exec-hook rule to perform
this step during "make install". There does not appear to be a Libtool
option to skip the use of ar(1), which would be a preferable approach.

--Daniel

-- 
NAME = Daniel Richard G.     _\|/_    Remember, skunks
MAIL = [email-masked]     (/o|o\) _- don't smell bad---
MAIL+= [email-masked]   < (^),>     it's the people who
WWW  = (not there yet!)      /   \      annoy us that do!