error: linker `cc` not found Rust Origin: Application & API OSI layer 7 · Application Last updated 5 Nov 2026

Rust: error: linker `cc` not found — note: No such file or directory (os error 2)

Rust needs a C linker (gcc/clang) to produce executables, and none is installed.

Exact message you may see error: linker `cc` not founderror: linker `link.exe` not foundnote: No such file or directory (os error 2) linker ccerror: could not compile `x` (bin) due to previous error linker not founderror: linking with `cc` failed: exit status: 1
Seen on: Rust Linux

Meaning

Install a toolchain: Debian/Ubuntu sudo apt install build-essential, Fedora sudo dnf install gcc, Alpine apk add build-base, macOS xcode-select --install, Windows MSVC Build Tools (the "linker link.exe not found" variant). Docker images like rust:slim may need build-essential for crates with C code.

Common causes

  • build-essential/gcc not installed
  • Minimal Docker image
  • Windows without MSVC Build Tools (link.exe)
  • macOS without Xcode CLT
  • Cross compiling without a target linker

⚡ Quick fix

  1. sudo apt install build-essential (or OS equivalent)
  2. Windows: install Visual Studio Build Tools (C++ workload)
  3. Set the linker for cross targets in .cargo/config.toml

Detailed fix by platform

Linux

  1. which cc gcc ld && sudo apt install -y build-essential

How to diagnose

  1. Linker — cc/link.exe?
  2. OS — Which package?
  3. Cross — Target linker?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Blocking waiting for file lock on package cache / build directory — Cargo: Blocking waiting for file lock on package cache / on build directory (Rust)Blocking waiting for …cargo: failed to get from registry (spurious network error) — Cargo: warning: spurious network error (2 tries remaining): [35] SSL connect error / error: failed to download from `https://index.crates.io/...` (Rust)cargo: failed to get …cargo: failed to select a version for the requirement — Cargo: error: failed to select a version for the requirement `serde = "^2.0"` — candidate versions found which didn't match: 1.0.197 (Rust)cargo: failed to sele…cgo: C compiler gcc not found — Go: cgo: C compiler "gcc" not found: exec: "gcc": executable file not found in $PATH (Go)cgo: C compiler gcc n…E0133: call to unsafe function requires unsafe block — Rust: error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block (Rust)E0133: call to unsafe…E0658: use of unstable library feature — Rust: error[E0658]: use of unstable library feature `let_chains` / `#![feature]` may not be used on the stable release channel (Rust)E0658: use of unstabl…error: toolchain 'stable' is not installed / override toolchain not found — rustup: error: toolchain 'nightly-x86_64-unknown-linux-gnu' is not installed / error: no override and no default toolchain set (Rust)error: toolchain 'sta…failed to run custom build command for openssl-sys — Cargo: error: failed to run custom build command for `openssl-sys v0.9.99` — Could not find directory of OpenSSL installation / pkg-config not found (Rust)failed to run custom …error: li…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.