libtool
[Top][All Lists]
Advanced

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

Re: Linking just some static


From: Jan Engelhardt
Subject: Re: Linking just some static
Date: Tue, 17 Feb 2009 00:56:39 +0100 (CET)
User-agent: Alpine 2.00 (LSU 1167 2008-08-23)

Hi Ralf,

On Monday 2009-02-16 19:56, Ralf Wildenhues wrote:
>> 
>> is it somehow possible to specify that only a given set of libraries is 
>> supposed to be linked in statically into a program? Something along the 
>> lines of...
>> 
>> bin_PROGRAMS = foo bar
>> foo_LDADD = libabc.la -( -static libdef.la -) libghi.la
>> bar_LDADD = libdef.la libghi.la
>
>With this patch, it would be possible, using -Bstatic and -Bdynamic:
><http://thread.gmane.org/gmane.comp.gnu.libtool.patches/6727/focus=6730>
>
>Can you try out the patch, and report back?

It works, but does not yet deal with some cases.

My first try was:

  p1_LDADD = -Bstatic libours.la -Bdynamic libtheirs.la

automake then responded:

  Makefile.am:11: linker flags such as `-Bstatic' belong in `p1_LDFLAGS'

I had naturally added -Bstatic to p1_LDADD because that is where all
the libraries are. Moving it to p1_LDFLAGS means that I give up
part of the dependency tracking — `make p1` will then not built
libours.la beforehand.

The other issue is that since -Bstatic is passed verbatim down to ld,
I get an error:

  CCLD     p1

  /bin/sh ./libtool  --tag=CC   --mode=link gcc -Wall -g -O2
  -Bstatic libours.la -Bdynamic libtheirs.la  -o p1 p1.o  

  libtool: link: gcc -Wall -g -O2 -o .libs/p1 p1.o   -Wl,-Bstatic
  ./.libs/libours.a /usr/lib/libHX.so -ldl -Wl,-Bdynamic ./.libs/libtheirs.so 

  /usr/lib/gcc/i586-suse-linux/4.3/../../../../i586-suse-linux/bin/ld:
  attempted static link of dynamic object `/usr/lib/libHX.so'

The (simplified) Makefile goes like:

  libours_la_LIBADD = -lHX
  p1_LDFLAGS = -Bstatic libours.la -Bdynamic libtheirs.la

[libHX is a library for which I do not have a static .a version installed.]

What I had in mind though was not what libtool currently does
(namely, passing -Bstatic/dynamic to the linker verbatim), but something
more along the lines of the libtool "-static" flag, that is, the
linker to be called with

  gcc -Wall -g -O2 -o .libs/p1 p1.o .libs/libours.a /usr/lib/libHX.so
  -ldl .libs/libtheirs.so



thanks,
Jan




reply via email to

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