How do you make a shared library on RISC System/6000
Marc J. Stephenson/140000;1C-22
marc at stingray.austin.ibm.com
Fri Jul 27 08:45:54 AEST 1990
In article <921 at nlsun1.oracle.nl> bengsig at oracle.nl (Bjorn Engsig) writes:
>[ experiences with trying to build shared libraries omitted ]
>I need to know:
> - which ld options (and export files) are needed to make shared object?
-bM:Sre is the important one. Your export list should consist on whatever
symbols are directly referenced from your non-shared portion. One easy
way to determine that is to try to link without the library, then
pick up the unresolved symbols as your export list. I'm afraid of wording
this one badly, but another requirement is that the shared library must
be fully linked. That is, it can have no unresolved references which
are not resolved by imports from other libraries. See the example the
bottom
> - are there any special ar options needed to put these into an archive?
No.
> - which ld (cc) options are needed to link my program with this shared archive?
Nothing different than with normal archives.
> - Do I need to set the LIBPATH environment?
Only if your archive is going to reside in a non-standard place, that is, other
than /lib or /usr/lib.
Otherwise, use LIBPATH=/lib:/usr/lib:$WHEREVER_YOUR_ARCHIVES_ARE, and export
LIBPATH. If you foul up setting your LIBPATH, you will start getting "Killed"
on normal commands. You would need to reset your LIBPATH at that time.
>
>Thanks for any help - in particular a working example.
>--
>Bjorn Engsig, Domain: bengsig at oracle.nl, bengsig at oracle.com
> Path: uunet!mcsun!orcenl!bengsig
Follows is a working example (please don't quibble with ar options & rot).
For my application, I have a shared portion (shr.o) which I keep in
library (libshr.a). My makefile looks like this: (names changed to protect me)
shr.o: ${SHARED_OBJECTS}
ld -D0 -H512 -T512 -bM:Sre -o shr.o ${SHARED_OBJECTS} /lib/libc.a -bexport:mylib.exp
mylib.a: shr.o
ar qv mylib.a shr.o
myprog: ${NON_SHARED_OBJECTS} mylib.a
cc ${CFLAGS} ${NON_SHARED_OBJECTS} mylib.a -o myprog
It also has @echo " eat death scum", but that's probably
unnecessary. :-)
--
Marc Stephenson (marc at stingray.austin.ibm.com)
DISCLAIMER: The content of this posting is independent of official IBM position.
External: uunet!cs.utexas.edu!ibmaus!auschs!stingray.austin.ibm.com!marc
Internal: marc at stingray.austin.ibm.com VNET: MARC at AUSVMQ T/L: 793-3796
More information about the Comp.unix.aix
mailing list