how do libtool convinience libraries work ?

Thiago Macieira thiago at kde.org
Sun Apr 24 19:15:50 BST 2005


Alexander Neundorf wrote:
>If it is linked using libtool, the contents of the static lib are
> inserted into the shared lib.
>What does libtool magically do ?

Magic trickery :-)

>I mean, in the end it must come down to some gcc/ld/ar/ranlib options I
> think.
>
>So, can anybody shed some light on me, how can I have the same effect
>manually ?

Sure.

I've just found it out too:

$ nm m1.o
00000000 T func1
$ nm m2.o
00000000 T func2
$ ar r libconv.a m1.o
ar: creating libconv.a

Wrong way:
$ gcc -shared -o libshared.so m2.o libconv.a
$ nm libshared.so | grep func.
00000478 T func2

Right way:
$ gcc -shared -o libshared.so m2.o -Wl,--whole-archive libconv.a 
-Wl,--no-whole-archive
$ nm libshared.so | grep func.
0000049c T func1
00000494 T func2

So, note: don't forget the --no-whole-archive in the end, or ld will try 
to include other system libraries into your library.

Hint: use -nostdlib as well.

-- 
  Thiago Macieira  -  thiago (AT) macieira (DOT) info
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

4. And æfter se scieppend ingelogode, he wrát "cenn", ac eala! se 
rihtendgesamnung andswarode "cenn: ne wát hú cennan 'eall'. Ástynt."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20050424/818e720c/attachment.sig>


More information about the kde-core-devel mailing list