What this thread does
cgo: C compiler "gcc" not found
The Go build needs C compilation, but its selected gcc executable is unavailable in the build process's PATH.
Do first: run go env CGO_ENABLED CC GOOS GOARCH GOHOSTOS GOHOSTARCH; decide whether this is a native build and which compiler CC selects. Go command reference, cgo compiler selection
Evidence: official cgo docs establish compiler selection and cross-build requirements; an August 4, 2024 user report records the missing-compiler error after enabling cgo. margani also records “64-bit mode not compiled in” with a mismatched compiler; that old installer is not a current recommendation. margani's report, official diagnostic example
Not for: Rust CLI cross-compilation; see how-do-i-ship-a-rust-cli-as-self-contained-binaries-for
Diagnostic: cgo compiler discovery
As of November 2026, the Go branches below target Go 1.27.0; its cgo reference is dated August 19, 2026. The SQLite example is pinned separately to go-sqlite3 v1.14.32. Versioned cgo reference, Go 1.27 release notes
Choose the branch
1. Native build, gcc is absent → install a C toolchain in the build environment. For Go 1.27.0 on Ubuntu, install build-essential; on macOS, install the command line tools with xcode-select --install. In the same session that starts Go, run gcc --version or clang --version, then CGO_ENABLED=1 go build ./.... If selecting Clang explicitly, use CC=clang CGO_ENABLED=1 go build ./.... Confirmation is that C compilation starts and the package build completes. Official C compiler prerequisite, platform installation commands, cgo CC override
2. A compiler exists but CC names a missing executable → correct that invocation's CC. On Go 1.27.0, if clang --version succeeds in the build session, try CC=clang CGO_ENABLED=1 go build ./.... Update the build script or environment that supplied the stale compiler name. Confirmation is the original build succeeding with the intended compiler; installing gcc in a different container stage or host session does not change this process's PATH. Compiler-selection contract
3. GOOS/GOARCH differ from the host → supply a target C compiler. On Go 1.27.0, a native gcc is insufficient for a different target. For the go-sqlite3 v1.14.32 Linux ARM example, install the matching cross-toolchain, then use CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=7 go build -v. Confirm the build completes, then run the binary on the target and exercise a database operation. This command is for that target, not a template to copy unchanged for another CPU or libc. Versioned driver README, official cross-compiling rules
Limits
Setting CGO_ENABLED=0 excludes files importing C; it is a valid alternative only when the selected dependencies support a useful pure-Go build. go-sqlite3 v1.14.32 explicitly requires cgo and gcc. A build that merely produces its no-cgo stub is not confirmation of database functionality. Driver requirements, dated stub report
Compiler discovery, missing C headers, and missing native libraries are different failures. Once gcc starts, use the next diagnostic rather than continuing to change PATH.
Started from a post by @The Go Authors, packaged by the editor. Original post