rsgain icon indicating copy to clipboard operation
rsgain copied to clipboard

Static Build

Open 239 opened this issue 1 year ago • 1 comments

The linked static build is dynamically linked: rsgain: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8db9147d84680a11afabe2d5694e370bbdcb22f0, for GNU/Linux 3.2.0, stripped

        linux-vdso.so.1 (0x000079430b919000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0000794309e00000)
        libm.so.6 => /usr/lib/libm.so.6 (0x000079430b7fb000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x000079430b7cd000)
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x000079430b7c8000)
        libc.so.6 => /usr/lib/libc.so.6 (0x0000794309c0f000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x000079430b91b000)

239 avatar Oct 22 '24 10:10 239

Thanks for this great tool — I’ve been experimenting with building a fully static version of rsgain for reproducible deployment. I’ve documented a step-by-step build process using only upstream dependencies (all built as static), suitable for modern Debian/Ubuntu systems — successfully tested with static builds on both amd64 and arm64 architectures.

# Install required packages
sudo apt update && sudo apt install -y \
build-essential cmake meson git wget curl nasm python3 \
ca-certificates pkg-config libtool autoconf automake unzip \
libutfcpp-dev ninja-build

# zlib (static)
wget http://www.zlib.net/zlib-1.3.1.tar.gz
tar -xvf zlib-1.3.1.tar.gz
cd zlib-1.3.1
./configure --static --prefix=/usr/local
make -j$(nproc)
sudo make install
cd ..

# FFmpeg (headers only, no binaries)
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --prefix=/usr/local --enable-static --disable-shared --disable-programs
make -j$(nproc)
sudo make install
cd ..

# taglib (static)
git clone https://github.com/taglib/taglib.git
cd taglib && mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)
sudo make install
cd ../..

# libebur128 (static)
git clone https://github.com/jiixyj/libebur128.git
cd libebur128 && mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)
sudo make install
cd ../..

# inih (static)
git clone https://github.com/benhoyt/inih.git
cd inih && mkdir build
meson setup build --prefix=/usr/local --buildtype=release -Ddefault_library=static
meson compile -C build
sudo meson install -C build
cd ..

# fmtlib (static)
git clone --recursive https://github.com/fmtlib/fmt.git
cd fmt && mkdir build && cd build
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)
sudo make install
cd ../..

# rsgain (static)
git clone https://github.com/complexlogic/rsgain.git
cd rsgain && mkdir build && cd build
cmake .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DBUILD_SHARED_LIBS=OFF \
  -DCMAKE_EXE_LINKER_FLAGS="-static" \
  -DCMAKE_INSTALL_PREFIX=/usr/local
make -j$(nproc)

The final binary can be stripped and copied easily for packaging or GitHub Releases:

strip build/rsgain
ldd build/rsgain
	not a dynamic executable

rsgain 3.6 - using:
   libebur128     1.2.6
   libavformat    62.0.100
   libavcodec     62.0.101
   libavutil      60.1.100
   libswresample  6.0.100
   TagLib         2.0.2

Compiler:         GCC 13.3
Build Date:       2025-04-09

Let me know if you’d be open to a small script or CI addition to help automate multi-arch static builds — I’d be happy to contribute that as well. 🙌

laamalif avatar Apr 09 '25 13:04 laamalif