[Top][All Lists]

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

Re: How to link just one library staticly.

From: Ralf Wildenhues
Subject: Re: How to link just one library staticly.
Date: Tue, 9 May 2006 13:14:15 +0200
User-agent: Mutt/1.5.11

Hi Paul,

* Paul Elliott wrote on Tue, May 09, 2006 at 12:09:12PM CEST:
> Because one library is a constantly changing moving target, and is
> small, I want to it link staticly. It is not a libtool library. It
> comes in .a and .so versions in /usr/lib.
> How do I tell automake to link that one library static and not
> the others.

The question is, how portable do you want it to be?

> I tied to add ".a" to the _LDADD entries in
> but that resulted in an error at link time:
> /bin/ls: /usr/libboost_filesystem.a: No such file or directory

This error message seems to come from 'ls' and not 'ld', so something
seems wrong here.  Other than that, is should've probably been
/usr/lib/libboost_filesystem.a instead of /usr/libboost_filesystem.a.

If you want to build your program on your host only, then hard-coding
that as above would be fine.  But in general you won't be able to assume
that libboost_filesystem lives in /usr/lib, or the one that lives there
is the one your users would like to use.  On some systems[1], it works
to use
  -Wl,-Bstatic -lLIB -Wl,-Bdynamic

in order to link LIB statically.  (Maybe a macro to provide this
portably should be given, maybe even independent of Libtool; FWIW,
there is a pending patch to provide this functionality portably with

You could also imitate Libtool's walk over the list of directories to
search, and look for $LIB.a, and list that hard-coded.  Note that this
will fail for AIX (where libfoo.a may be a shared library) and for some
w32 environments (where static libraries may also end in '.lib', and
where '.a' libraries may be import libraries for DLLs).



reply via email to

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