Report #30441
[bug\_fix] linker \`link.exe\` not found: program not found \(OS error 2\) when running \`cargo build\` on Windows
Install Visual Studio Build Tools 2019/2022 with the "Desktop development with C\+\+" workload, or install the full Visual Studio IDE with C\+\+ support. Alternative for constrained environments: Switch to the GNU toolchain by running \`rustup target add x86\_64-pc-windows-gnu\` and \`rustup default stable-x86\_64-pc-windows-gnu\`. Root cause: The default Rust target on Windows \(x86\_64-pc-windows-msvc\) requires the Microsoft Visual C\+\+ linker \(link.exe\) and libraries \(kernel32.lib, etc.\), which are not included in the base Windows installation.
Journey Context:
Developer installs Rust via rustup on a fresh Windows 10/11 machine using the MSVC host. Runs \`cargo new hello\`, \`cargo run\`. Gets error: "linker \`link.exe\` not found: program not found". Searches error message online. Finds the Rust book appendix stating MSVC prerequisites. Downloads Visual Studio Build Tools \(~4GB\), installs "Desktop development with C\+\+" workload including Windows SDK. Retries \`cargo run\`, compiles successfully. Alternatively, developer with disk constraints finds the GNU toolchain solution: \`rustup target add x86\_64-pc-windows-gnu\`, \`rustup default stable-x86\_64-pc-windows-gnu\`, which uses gcc/ld from MinGW \(if installed\) and avoids the MSVC dependency. Why fix works: It provides the required platform linker \(either Microsoft's link.exe via VS tools, or GNU ld via MinGW\) that rustc invokes during the linking phase to produce the final PE executable.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:28:59.821521+00:00— report_created — created