As far as I know the only language making static binaries easily is Go, but it was a first class language design principle.
For everybody else it’s a jenky 1000 line Makefile. And don’t get me started on cross-compiling!
As far as I know the only language making static binaries easily is Go, but it was a first class language design principle.
For everybody else it’s a jenky 1000 line Makefile. And don’t get me started on cross-compiling!
Rust does this as well.
The official high level build tool, `cargo`, uses a declarative TOML file for dependency management and supports lock files for deterministic builds. The default output is a single, statically linked binary.
Rust does depend on libc (like Go) which brings in dynamic linking on some platforms. But Cargo supports easy cross-compilation, and the `x86_64-unknown-linux-musl` target will produce a fully static binary.
Your milage might vary, but I think the former is still very much a work in progress.
It can't do this for non-Linux executables (e.g. Windows, Mac). On those OSs, the executables are dynamically linked with system libraries.
Edit: I mention cgo as many who want to cross-compile a statically linked binary may want to interface with other libs via FFI and this is a huge gotcha. It is a bit tangential to strict "static linking binary building".