Subject: Re: bug#9316: AIX and JNI: *.so versus *.a

From: Peter O'Gorman <[email-masked]>
Date: Fri, 19 Aug 2011 22:55:45 -0500

On Aug 17, 2011, at 4:58 PM, Daniel Richard G. wrote:

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

Hi,

If you add -Wl,-brtl to LDFLAGS at configure time, libtool will build plain .so's

Peter

> 
> 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!
> 
> 
> 
> _______________________________________________
> Bug-libtool mailing list
> [email-masked]
> https://lists.gnu.org/mailman/listinfo/bug-libtool
> 

--
Peter O'Gorman
http://pogma.com