How to get a static binary from ports

Karol Kwiatkowski karol.kwiat at gmail.com
Thu Sep 6 01:14:45 PDT 2007


Jeremy Chadwick 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.

Yes, I'm aware of this. I was asked to do that so that the binary can be
run on other systems. That's not my idea but as I understand, they can
use only static binaries on some hosts.

> 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.

As Scot pointed in another email, I've already got them (.a files)
The only step I'm missing is hot to include them in final binary instead
of linking to .so libraries.

> 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.

Hmm... I've looked at cvsup but it's using M3FLAGS. I'll take a look at
other ports, thanks for the tip!

Cheers,

Karol

-- 
Karol Kwiatkowski   <karol.kwiat at gmail dot com>
OpenPGP 0x06E09309

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 542 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20070906/b3ee45c2/signature.pgp


More information about the freebsd-ports mailing list