GNU bug report logs - #9316
AIX and JNI: *.so versus *.a

Previous Next

Package: libtool;

Reported by: "Daniel Richard G." <skunk <at> iSKUNK.ORG>

Date: Wed, 17 Aug 2011 22:01:02 UTC

Severity: normal

To reply to this bug, email your comments to 9316 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-libtool <at> gnu.org:
bug#9316; Package libtool. (Wed, 17 Aug 2011 22:01:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Daniel Richard G." <skunk <at> iSKUNK.ORG>:
New bug report received and forwarded. Copy sent to bug-libtool <at> gnu.org. (Wed, 17 Aug 2011 22:01:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Daniel Richard G." <skunk <at> iSKUNK.ORG>
To: bug-libtool <at> gnu.org
Subject: AIX and JNI: *.so versus *.a
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 = skunk <at> iSKUNK.ORG     (/o|o\) _- don't smell bad---
MAIL+= skunk <at> alum.MIT.EDU   < (^),>     it's the people who
WWW  = (not there yet!)      /   \      annoy us that do!




Information forwarded to owner <at> debbugs.gnu.org, bug-libtool <at> gnu.org:
bug#9316; Package libtool. (Sat, 20 Aug 2011 04:26:01 GMT) Full text and rfc822 format available.

Message #8 received at 9316 <at> debbugs.gnu.org (full text, mbox):

From: "Daniel Richard G." <skunk <at> iSKUNK.ORG>
To: "Peter O'Gorman" <peter <at> pogma.com>
Cc: 9316 <at> debbugs.gnu.org
Subject: Re: bug#9316: AIX and JNI: *.so versus *.a
Date: Sat, 20 Aug 2011 00:23:17 -0400
On Fri, 2011 Aug 19 22:55-0500, Peter O'Gorman wrote:
>
> If you add -Wl,-brtl to LDFLAGS at configure time, libtool will build
> plain .so's

Interesting. This bit from doc/notes.txt in the Libtool source
distribution seems relevant:

   * On AIX there are two different styles of shared linking, one in
     which symbols are bound at link-time and one in which symbols are
     bound at runtime only, similar to ELF.  In case of doubt use
     `LDFLAGS=-Wl,-brtl' for the latter style.

Why isn't Libtool itself already adding this flag when -module is
specified?




Information forwarded to owner <at> debbugs.gnu.org, bug-libtool <at> gnu.org:
bug#9316; Package libtool. (Sat, 20 Aug 2011 14:06:03 GMT) Full text and rfc822 format available.

Message #11 received at 9316 <at> debbugs.gnu.org (full text, mbox):

From: Peter O'Gorman <peter <at> pogma.com>
To: Daniel Richard G. <skunk <at> iSKUNK.ORG>
Cc: 9316 <at> debbugs.gnu.org
Subject: Re: bug#9316: AIX and JNI: *.so versus *.a
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 = skunk <at> iSKUNK.ORG     (/o|o\) _- don't smell bad---
> MAIL+= skunk <at> alum.MIT.EDU   < (^),>     it's the people who
> WWW  = (not there yet!)      /   \      annoy us that do!
> 
> 
> 
> _______________________________________________
> Bug-libtool mailing list
> Bug-libtool <at> gnu.org
> https://lists.gnu.org/mailman/listinfo/bug-libtool
> 

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






This bug report was last modified 13 years and 306 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.