libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Including static libraries in shared libraries with libtool.


From: Simon Richter
Subject: Re: Including static libraries in shared libraries with libtool.
Date: Sun, 26 Sep 2004 20:47:18 +0200
User-agent: Mutt/1.5.6+20040818i

Hi,

> My intentions here are:

> Build the sources for libauthuserdb.la.  Take their object code, and grab 
> whatever modules from libauth.la that are references by stuff in 
> libauthuserdb.la, and place all of that into a shared library.

Not possible without reimplementing parts of the linker.

Parts of static libraries cannot be linked into shared libraries, as
shared libs need to be compiled as position independent code (ld.so on
ix86 linux can work around that by mapping the offending library into a
private mapping and relocating it, but that is a huge waste of memory
and not portable).

> Unfortunately, the actual results are different.  There are two problem:

> 1. Libtool takes _all_ modules from libauth.la, and puts them into 
> libauthuserdb.la.  I only want the modules that libauthuserdb.la actually 
> needs.

A "convenience library", as a libtool library that is not installed is
called, is linked into each object that uses it. If the object is a
library, it is copied completely, otherwise, it is linked statically.
This feature is intended for huge libraries that are built from multiple
subdirectories, where each subdir builds a convenience lib and
everything is linked in the end.

> 2. For some reason, only the static version of libauthuserdb.la is 
> generated.  I don't know why, but libauthuserdb.so is not created, only 
> libauthuserdb.a is created.  I am _not_ using the --disable-shared flag 
> with the configure script.

There is no way to build a shared library, as parts of it are only
available as non-PIC code.

> However, this is not practical.  I'm building several shared libraries that 
> use different bits and pieces of the common code, and manually tracking 
> which common source module is used by which shared library is cumbersome. I 
> need to coerce libtool in doing this job for me.

If there may be additional shared libs that may be built outside of the
source tree, you may be better off making a ...-util library that is
installed and linked by all of your other libraries. This is transparent
to the user, but permits everyone to write their own libraries linking
against the -util library.

   Simon

-- 
 GPG Fingerprint: 040E B5F7 84F1 4FBC CEAD  ADC6 18A0 CC8D 5706 A4B4

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]