cross compilation
Building a program on one kind of machine for a different operating system or processor, such as a Linux binary on a Mac.
In more detail
It lets one build machine produce programs for every platform you ship to, such as a laptop producing a Linux build for a container. Some languages need a separate toolchain per target; others, such as Go, only need a setting changed. Code that links to C libraries usually needs a C toolchain for the target too.
Example
GOOS=linux GOARCH=amd64 go build -o probe .Related terms
- GOOS and GOARCH — The two Go settings that choose the target operating system and processor family a build produces a binary for.
- cgo — The Go feature that lets Go code call C code, which links the program to C libraries on the build and target machines.
- go build — The go subcommand that compiles a package and its dependencies into an executable file and prints nothing when it succeeds.
- CPU architecture — The family of instructions a processor understands, such as 64-bit Intel (amd64) or 64-bit Arm (arm64).
Taught in
- What Go Is and Why It Matters — Concurrent Systems Programming with Go
- Building Static Binaries — Concurrent Systems Programming with Go