[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Install of libtool module on AIX 4.2 does not work.
From: |
Gary Kumfert |
Subject: |
Re: Install of libtool module on AIX 4.2 does not work. |
Date: |
Fri, 14 Jan 2005 17:04:55 -0800 (PST) |
On Fri, 14 Jan 2005, Albert Chin wrote:
> On Fri, Jan 14, 2005 at 09:28:54PM +0100, Peter Ekberg wrote:
> > Albert Chin wrote:
> > > On Thu, Jan 13, 2005 at 07:32:46PM +0100, Peter Ekberg wrote:
> > >> Albert Chin wrote:
> > >>> On Tue, Jan 11, 2005 at 06:31:19PM +0100, Peter Ekberg wrote:
> > >>>> When installing a "libtool module" on aix 4.2, the .so file is not
> > >>>> installed, even though the .la file specifies:
> > >>>> dlname='x.so'
> > >>>>
> > >>>> Copying x.so to the intended directory makes it work. However,
> > >>>> trying to dlopen more than one such DSO does not work for some
> > >>>> reason yet unknown to me. But one is better than none, no?
> > >>>
> > >>> Rebuild with LDFLAGS="-Wl,-brtl".
> > >>
> > >> Ok, I reconfigured with LDFLAGS="-Wl,brtl", which I assume stands
> > >> for "run time linking" or something like that?
> > >
> > > -brtl, not brtl.
> >
> > Doh!
> >
> > Yes, that works. Thanks a bunch!
> >
> > Do you know when exacly this flag is needed? (I.e. why does not
> > configure figure out it's needed?)
>
> I always use it. AIX can use two types of shared libraries. System-V
> type shared libraries aren't the default so they're not used.
>
There aren't two types of shared libraries... there's shared
and there's dynamic (or "run time linked" in AIX speak. hence -brtl.)
Even then, the switch doesn't *really* care about the type... just the
suffix in the filesystem. (Below is an exercise I just did
to confirm this.)
The bigger issue in Peter's question, I thought was:
why should he (or me, or my customers for that matter) have to know
to configure with "LDFLAGS=-brtl" in the first place?
The point of libtool is to hide such platform-specific details.
(I concede that its not easy since AIX has a unique mapping of
the 3 linkage concepts [static, shared, dynamic] onto the two
file suffices [*.a, *.so]. OTOH, I suppose IBM figures its a
novel feature of ELF that all shared libraries can be dynamically
loaded.)
Requiring LDFLAGS=-brtl at configure time is IMHO a bit
heavy-handed. In my own build, I don't want -brtl to show up
*everywhere*.... only certain places.
I'd much rather specify it my makefiles using a
platform-independent libtool option, and let libtool intuit
that its "-Wl,-brtl" on AIX, and "" elsewhere.
Respectfully submitted,
Gary
------------------------------------------------------------------------
Gary Kumfert, Ph.D. <address@hidden>
Center for Applied Scientific Computing phone: 925-424-2580
Lawrence Livermore National Laboratory fax: 925-424-2477
P.O. Box 808, L-365
Livermore, CA 94551-0808
P.S. For all kinds of nitty-gritty's, I recommend
http://www.ibm.com/developerworks/eserver/pdfs/aix_ll.pdf
and (even grittier)
Linkers & Loaders. John Levine. Morgan Kaufman Publishing
P.P.S. Now for the exercise which builds a lib*.a and then renames
it lib*.so to indicate -brtl really is a filename thing,
not a library-type issue.
> cat foo1.c
#include <stdio.h>
foo() {
printf("foo1\n");
}
> cat foo2.c
#include <stdio.h>
foo() {
printf("foo2\n");
}
> cat main.c
int main() {
foo();
}
> xlc -g -c foo1.c
> ar cru libfoo.a foo1.o
> ranlib libfoo.a
> mv libfoo.a libfoo.so # if its a type thing, maybe this would upset it?
> xlc -g -c foo2.c
> ar cru libfoo.a foo2.o
> ranlib libfoo.a
> xlc -brtl -o main1 main.c -L. -lfoo # this picks up libfoo.so (foo1.o)
> xlc -o main2 main.c -L -lfoo # this picks up libfoo.a (foo2.o)
> ./main1
foo1
> ./main2
foo2
The AIX *convention* is to reserve the *.so suffix for dynamic loaded
libraries ("run time linkage" in AIX-speak.... which is probably the
reason for the flag's name -brtl). It seems intended to apply shared
linkage to run-time linked libraries. (Which makes sense since in AIX,
there's also a switch to apply static linkage to otherwise shared
libraries). Note that if I build libfoo.so the usual way, this also works
> xlc -G -o libfoo.so foo3.o #assume this prints foo3, without me showing code
> ./main1 # no need to relink main1
foo3
I didn't bother trying to dlopen a library built with ar.
We all know what happens there on AIX. ;)
Gary