Skip to content

Instantly share code, notes, and snippets.

@hed0rah
Created March 20, 2026 03:29
Show Gist options
  • Select an option

  • Save hed0rah/cccebca31b78604a7ec40ef87b705edc to your computer and use it in GitHub Desktop.

Select an option

Save hed0rah/cccebca31b78604a7ec40ef87b705edc to your computer and use it in GitHub Desktop.
Build BusyBox

Building Busybox from Source

busybox.net has been unreliable. Source mirrors:

git clone https://git.busybox.net/busybox
# or
git clone https://github.com/mirror/busybox

Dependencies

# debian/ubuntu
sudo apt install build-essential libncurses-dev pkg-config

# alpine
apk add build-base ncurses-dev

# arch
pacman -S base-devel ncurses

GCC 14+ Fix

GCC 14 (Debian trixie, Ubuntu 24.04+, Fedora 40+) promotes -Wimplicit-int from warning to error. Busybox's ncurses check script has main() {} instead of int main() {}, so make menuconfig fails with a misleading "Unable to find the ncurses libraries" even though the libraries are installed and pkg-config resolves fine.

Fix:

sed -i 's/main() {}/int main() {}/' scripts/kconfig/lxdialog/check-lxdialog.sh

Or if you want to be thorough:

sed -i \
  -e 's/main() {}/int main() {}/' \
  -e 's/\$cc -x c/\$cc -x c -Wno-implicit-int/' \
  scripts/kconfig/lxdialog/check-lxdialog.sh

Option A: menuconfig (interactive)

make menuconfig

Navigate Settings -> Build Options -> Build static binary (no shared libs) if you want a static build. Save and exit.

make -j$(nproc)

Option B: defconfig + static (non-interactive)

make defconfig
sed -i 's/# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config
make -j$(nproc)

Output

Binary: ./busybox

Symlink tree (one symlink per applet):

make install
# installs to ./_install/ by default
ls _install/bin/

Or install to a custom root:

make CONFIG_PREFIX=/path/to/rootfs install

Verify

./busybox --list | wc -l    # number of applets
./busybox --list | head -20  # see what's included
file ./busybox               # should say "statically linked" if you went static
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment