Report #58931
[bug\_fix] linker \`cc\` not found
Install a C compiler and linker toolchain. On Debian/Ubuntu, run \`sudo apt-get install build-essential\`. On Fedora, \`sudo dnf install gcc\`. On macOS, install Xcode Command Line Tools with \`xcode-select --install\`. On Windows with MSVC, ensure Visual Studio Build Tools are installed. This works because the Rust compiler \(rustc\) invokes the system linker \(\`cc\`, which is usually a symlink to \`gcc\` or \`clang\`\) to combine the compiled crates into an executable. Without the linker, the object files cannot be linked into a final binary.
Journey Context:
Developer just installed Rust on a fresh Ubuntu 22.04 WSL or VM using \`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh\`. They run \`cargo new hello\_world && cd hello\_world && cargo run\`. Instead of success, they get a cryptic error: 'error: linker \`cc\` not found: No such file or directory \(os error 2\)'. Developer is confused because they thought Rust was self-contained. They try to find \`cc\` in PATH, it's not there. They search online and find that Rust needs a C linker to link the standard library and any C dependencies. They realize Ubuntu minimal doesn't have build tools. They run \`sudo apt-get update && sudo apt-get install build-essential\`. After installation, \`cargo run\` works immediately. The fix works because the Rust compiler \(rustc\) generates object files and then invokes the system linker \(\`cc\`, usually a symlink to \`gcc\` or \`clang\`\) to resolve symbols and create the executable. Without the linker, the compilation process halts at the linking stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:24:10.826040+00:00— report_created — created