Gentoo Archives: gentoo-user

From: Albert Hopkins <marduk@×××××××××××.org>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Building static libraries
Date: Sun, 13 Dec 2009 20:41:13
Message-Id: 1260736834.11448.15.camel@centar
In Reply to: [gentoo-user] Building static libraries by Renat Golubchyk
1 On Sun, 2009-12-13 at 20:18 +0100, Renat Golubchyk wrote:
2 > Hi everyone!
3 >
4 > I need to build a static binary of a program I wrote. The problem is
5 > that most packages only install dynamic version of the libraries.
6 > There
7 > are the "static" and "static-libs" USE flags, but only a tiny fraction
8 > of packages support them. Modifying every relevant ebuild is not
9 > really
10 > a viable solution since the list of packages is quite long and could
11 > change later.
12 >
13 > So what can I do if I'd like to avoid compiling every package
14 > manually?
15
16 There is no easy answer to your question. I think because, with a lot of
17 programs it "just depends". Some packages already include static
18 libraries (e.g. python and it doesn't make sense to compile the python
19 package statically because it will break a great many things). Some
20 programs just weren't designed to be static (e.g. imagemagick or
21 apache). GTK+, i believe, can't be built statically as it uses dynload
22 for themes, input methods, etc etc. Even most proprietary gtk-based
23 software that I know of (e.g. Adobe Flash and VMWare) either are
24 distributed with GTK+ linked dynamically or they provide their own GTK
25 libs).
26
27 You can apply "-static" to CFLAGS, but make sure you have a binpkg built
28 first, as there is a chance you may break something. You can also try
29 passing "--enable-static" to EXTRA_ECONF. That's probably safer than
30 the former, but the same caveat applies.
31
32 Most of the things where static is "useful" and safe already have a
33 static flag though or provide static libs by default. I think the only
34 exception I've encountered was e2fsprogs. For that I usually compile my
35 own static executables.
36
37 HTH,
38 -a

Replies

Subject Author
Re: [gentoo-user] Building static libraries Renat Golubchyk <ragermany@×××.net>