Iperf: How to statically compile iperf3?

Created on 4 Apr 2017  ·  5Comments  ·  Source: esnet/iperf

Dear iperf3 developers,

I want to use iperf3 in a minimal filesystem with a linux kernel. i have to statically compile the programs to use inside the filesystem. Is that possible to statically compile iperf3?
I did
$ ./configure --build=arm-none-linux-gnueabi --host=arm-none-linux-gnueabi CFLAGS=-static CXXFLAGS=-static
$ make

But I get
/src$ file iperf3
iperf3: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=33df741e068aaf7a9ae8a24a6243de87c35c6ca5, not stripped

best regards,
Jiahuan

question

Most helpful comment

This worked for me:

./configure "LDFLAGS=--static" --disable-shared --without-sctp
make
make install
$ ldd iperf3 
    not a dynamic executable

It's also on the documentation: https://software.es.net/iperf/faq.html

All 5 comments

./configure --enable-static --disable-shared ; make ; make install

I haven't tried this for a long time, but that looks the right answer, thanks @TheRealDJ!

This does not seem to work anymore. It builds the static library but not the executables.

Hi,
I can confirm this. I tried building iperf3 as static executable but it still links against a few libraries:

❯ ldd ./iperf3
    linux-vdso.so.1 (0x00006284def24000)
    libcrypto.so.1.1 => /usr/lib/libcrypto.so.1.1 (0x00006284debef000)
    libc.so.6 => /usr/lib/libc.so.6 (0x00006284dea29000)
    libdl.so.2 => /usr/lib/libdl.so.2 (0x00006284dea24000)
    libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00006284dea02000)
    /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00006284def26000)

build via: ./configure --enable-static --disable-shared

This worked for me:

./configure "LDFLAGS=--static" --disable-shared --without-sctp
make
make install
$ ldd iperf3 
    not a dynamic executable

It's also on the documentation: https://software.es.net/iperf/faq.html

Was this page helpful?
0 / 5 - 0 ratings