How to get a static binary from ports
Scot Hetzel
swhetzel at gmail.com
Wed Sep 5 13:17:35 PDT 2007
On 9/5/07, Jeremy Chadwick <koitsu at freebsd.org> wrote:
> On Wed, Sep 05, 2007 at 08:45:15PM +0200, Karol Kwiatkowski wrote:
> > Hi all,
> >
> > to keep it short:
> >
> > is there any ports knob to statically link binaries?
> > If not, what steps should I take to modify a port?
> >
> > # ldd (...)/work/rrdtool-1.2.23/src/rrdtool
> > (...)/work/rrdtool-1.2.23/src/rrdtool:
> > libfreetype.so.9 => /usr/local/lib/libfreetype.so.9 (0x280cb000)
> > libpng.so.5 => /usr/local/lib/libpng.so.5 (0x28135000)
> > libz.so.4 => /lib/libz.so.4 (0x2815b000)
> > libart_lgpl_2.so.5 => /usr/local/lib/libart_lgpl_2.so.5 (0x2816d000)
> > libm.so.5 => /lib/libm.so.5 (0x28182000)
> > libc.so.7 => /lib/libc.so.7 (0x28197000)
> >
> > librrd.so.2 is now included statically, but the rest is not. I tried
> > various configure options like --enable-static, --disable-shared, also
> > added '-static' to CFLAGS and/or LDFLAGS in Makefile plus various
> > combinations of the above but that doesn't make a difference.
> >
> > How can I include the rest of the libraries in the binary?
>
> Why do you need this suite of applications statically-linked? There
> are many downsides to using statically-linked binaries, and many
> positives to using shared libraries. If you want to know the pros and
> cons to static (the cons outweigh the pros), I will be more than happy
> to provide you a detailed explanation.
>
> To directly answer your question: you need to build all the rest of
> those libraries as static as well; that is to say, you need
> libfreetype.a, libpng.a, libart_lgpl_2.a and so on.
>
> AFAIK, there is no "easy" way to do this. Each port has to be built
> with static capabilities. I believe an example port which does this
> is net/cvsup, using either the STATIC or WITH_STATIC knob.
>
Those files are already statically built and installed by 'make
buildworld/installworld' and each dependant port:
hp010# ls -l /usr/lib/{libz,libm,libc}.a
-r--r--r-- 1 root wheel 3166840 Sep 4 08:24 /usr/lib/libc.a
-r--r--r-- 1 root wheel 406978 Sep 4 08:25 /usr/lib/libm.a
-r--r--r-- 1 root wheel 109450 Sep 4 08:25 /usr/lib/libz.a
hp010# ls -l /usr/local/lib/{libfreetype,libpng,libart_lgpl_2}.a
-rw-r--r-- 1 root wheel 170422 Jun 9 03:31 /usr/local/lib/libart_lgpl_2.a
-rw-r--r-- 1 root wheel 681668 Jun 8 20:41 /usr/local/lib/libfreetype.a
-r--r--r-- 1 root wheel 237476 Jun 8 21:19 /usr/local/lib/libpng.a
Jeremy, check that you have these files.
Scot
More information about the freebsd-ports
mailing list