[Top][All Lists]

[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 = -( -static -)
>> bar_LDADD =
>With this patch, it would be possible, using -Bstatic and -Bdynamic:
>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 -Bdynamic

automake then responded: 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 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 -Bdynamic  -o p1 p1.o  

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

  attempted static link of dynamic object `/usr/lib/'

The (simplified) Makefile goes like:

  libours_la_LIBADD = -lHX
  p1_LDFLAGS = -Bstatic -Bdynamic

[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/
  -ldl .libs/


reply via email to

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