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: Sam Varshavchik
Subject: Re: Including static libraries in shared libraries with libtool.
Date: Sun, 26 Sep 2004 15:43:55 -0400

Simon Richter writes:

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).

I can create a static library from PIC modules that libtool already builds. It actually turns out to be fairly easy:

libshuserdb.a: libuserdb.la
       -rm -f $@
       cd .libs && $(AR) $(ARFLAGS) ../$@ $(libuserdb_la_OBJECTS:.lo=.o)

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.

Let's explore this possibility. I have about a dozen small components (a component=library) other. Each component is in its own subdirectory. It can be built, if necessary, by itself. The components are not installed, they are just building blocks.

Then, there are several installable shared libraries. Each shared library makes use of various bits and pieces from various component libraries.

Your suggestion, as I understand it, is to take all the small component libraries and put them together into a single -util, that every installable shared links against.

Fair enough, bit libtool doesn't seem to be able to do that.

libutil_la_SOURCES=[ file listing ]
libutil_la_LIBADD=subdir1/libcomponent1.la subdir2/libcomponent2.la

From what I can see, libtool is not going to add libcomponent1.la and
libcomponent2.la to the shared version of libutil.la, it will merely record their SONAME, and I still have to install libcomponent1.so and libcomponent2.so, in addition to libutil.so.

Now on the static side, it looks like libtool will methodically unpack libcomponent1.a and libcomponent2.a; then put all of the extracted modules into libutil.a, together with libutil.a's own object modules, so libutil.a has everything.

That, pretty much, is what I need to do with the shared library version as well. My component libraries are logically grouped, and each one is dedicated to a specific functionality. I'd rather not break everything up, and manually force everything into libutil.so, making for a big mess.

Attachment: pgp2kJheAFYI2.pgp
Description: PGP signature


reply via email to

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