Report #22827
[bug\_fix] Linker \`link.exe\` not found on Windows
The root cause is that Rust on Windows requires the Microsoft Visual C\+\+ \(MSVC\) toolchain linker \(link.exe\) to produce executables, but the Windows SDK or Visual Studio Build Tools are not installed or not in the PATH. The fix is to install the Visual Studio Build Tools \(specifically the 'Desktop development with C\+\+' workload\) or the full Visual Studio Community edition, ensuring the 'MSVC v143 - VS 2022 C\+\+ x64/x86 build tools' and 'Windows 10/11 SDK' components are selected. Alternatively, switch to the GNU toolchain with \`rustup default stable-x86\_64-pc-windows-gnu\` which uses GCC instead of MSVC, though this may cause compatibility issues with some C libraries.
Journey Context:
You just installed Rust via rustup on your Windows 11 machine. You run \`cargo new hello\_world && cd hello\_world && cargo build\` and immediately get a wall of text ending with 'linker \`link.exe\` not found'. You think 'I have GCC installed via MinGW, why isn't it using that?' You try adding MinGW to your PATH but the error persists because rustc defaults to the MSVC target on Windows. You search StackOverflow and find suggestions to install 'Visual Studio' but you don't want the full IDE. You try installing just the 'Visual C\+\+ Redistributable' but that doesn't provide the compiler tools. You try \`rustup toolchain install stable-x86\_64-pc-windows-gnu\` and switch to it, which works for this simple project, but when you later try to use a crate with C dependencies \(like \`openssl-sys\` or \`winapi\`\), you get cryptic compilation errors because the GNU toolchain expects different library formats. Finally, you download the 'Build Tools for Visual Studio 2022' from Microsoft's website, run the installer, check the 'Desktop development with C\+\+' workload, wait for the 3GB download, open a new PowerShell window \(crucial for PATH updates\), and \`cargo build\` succeeds. The fix works because rustc invokes \`link.exe\` \(the MSVC linker\) to create the final PE executable, and this tool is only provided by the Windows SDK components in the Build Tools.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:43:15.464018+00:00— report_created — created