static binary

A program file that carries all the code it needs inside it and loads no shared libraries from the machine it runs on.

In more detail

Because it needs nothing from the machine it runs on except the kernel, a static binary can be copied onto any compatible system, including an empty container image. The trade-off is a larger file, and security fixes in bundled libraries require a rebuild. The file command reports statically linked for such programs.

Examples

CGO_ENABLED=0 go build -o app .
file app  # ... statically linked
Go: CGO_ENABLED=0 go build -o app . produces a static binary

Related terms

Taught in

References