Skip to content

Instantly share code, notes, and snippets.

@GhostNaix
Created February 28, 2024 18:52
Show Gist options
  • Select an option

  • Save GhostNaix/b8e744420f75601156372fbe8b180220 to your computer and use it in GitHub Desktop.

Select an option

Save GhostNaix/b8e744420f75601156372fbe8b180220 to your computer and use it in GitHub Desktop.
Compile Iperf3 static binary on Gentoo

iperf3-static

Compiling Iperf3 statically on gentoo and cross-platform compile as well as on other platforms

Some Warnings

  • Configure doesn't like spaces in directories

Prep

I presumed you are cd into ~ or $HOME

mkdir Compile_Drop
cd Compile_Drop

Gentoo/Linux

Set USE FLAGS

sudo nano /etc/portage/package.use/openssl and insert the line dev-libs/openssl static-libs

Dependencies

Depedencies x64 sudo emerge openssl

Dependencies x86

sudo emerge openssl[abi_x86_32] --autounmask-write
sudo dispatch-conf
sudo emerge openssl[abi_x86_32]

Dependencies ARM (This step is only necessary if cross Compiling)

sudo emerge crossdev

Then follow this guide https://wiki.gentoo.org/wiki/Crossdev

crossdev --stable -t aarch64-unknown-linux-gnu
crossdev --stable -t arm-linux-gnueabi

Set static-lib use flags

sed -i 's/USE="${ARCH}"/USE="${ARCH} static-libs"/g' "/usr/aarch64-unknown-linux-gnu/etc/portage/make.conf"
sed -i 's/USE="${ARCH}"/USE="${ARCH} static-libs"/g' "/usr/arm-linux-gnueabi/etc/portage/make.conf"

Emerge and install openssl static-libs

emerge-arm-linux-gnueabi dev-libs/openssl -v
emerge-aarch64-unknown-linux-gnu dev-libs/openssl -v

Compile commands x86/x64

./bootstrap.sh

Compile x64

./configure --enable-static-bin --disable-shared 
make -j$(nproc)
strip -s src/iperf3

Compile x86

export CC="gcc -m32"
export CXX="g++ -m32"
./configure --enable-static-bin --disable-shared 
make -j$(nproc)
strip -s src/iperf3
unset CC
unset CXX

Compile commands for ARM system

Compile ARM (Something is wrong with the ARM cross compiler so only works up to v3.15)

Replace the configure command ./configure --host=arm-linux-gnueabi --enable-static-bin --with-openssl="${HOME}/Compile_Drop/opensslARM" with ./configure --host=arm-linux-gnueabi --enable-static-bin --with-openssl="${HOME}/Compile_Drop/opensslARM" --disable-shared LDFLAGS="-latomic" and compile on ubuntu instead.

# You might want to change this line to a valid directory where you compiled stored openssl
./configure --host=arm-linux-gnueabi --enable-static-bin --disable-shared 
make -j$(nproc)
arm-linux-gnueabi-strip -s src/iperf3

Compile ARM64

# You might want to change this line to a valid directory where you compiled stored openssl
./configure --host=aarch64-unknown-linux-gnu --enable-static-bin --disable-shared  
make -j$(nproc)
aarch64-unknown-linux-gnu-strip -s src/iperf3

Windows

Compile iperf3 on Windows x64

  • Install Cygwin
  • Install Wget
  • Run these commands
wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
apt-cyg install git nano make cmake extra-cmake-modules automake autoconf gcc-core gcc-g++ gdb binutils cygwin-devel w32api-headers w32api-runtime libguile3.0_1 libisl23 libmpc3 libgc1 libffi8
git clone https://github.com/esnet/iperf.git
cd iperf
./configure --enable-static-bin
make -j$(nproc)
make install

Compile iperf3 on Windows x86

  • Install Cygwin from https://cygwin.com/setup-x86.exe via setup-x86.exe --allow-unsupported-windows
  • set mirror to: http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457
  • Install wget
  • Run these commands
wget https://raw.githubusercontent.com/transcode-open/apt-cyg/master/apt-cyg
install apt-cyg /bin
apt-cyg install git nano make cmake extra-cmake-modules automake autoconf gcc-core gcc-g++ gdb binutils cygwin-devel w32api-headers w32api-runtime libguile3.0_1 libisl23 libmpc3 libgc1 libguile2.2_1 libltdl7
git clone https://github.com/esnet/iperf.git
cd iperf
./configure --enable-static-bin
make -j$(nproc)
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment