Fix Build Errors on Windows — Rust Troubleshooting
Solve missing linkers, SDK headers, unresolved symbols and architecture mismatches when building Rust apps on Windows.
Most frequent errors and fixes
link.exe not found
Install Visual Studio Build Tools (C++ workload). Open a fresh x64 Developer shell so PATH includes MSVC.
Missing Windows SDK headers/libs
Add Windows 10/11 SDK via Visual Studio Installer → Individual components. Reopen terminal.
LNK1104 / unresolved external symbol
Match architecture (x64), ensure SDK libs installed, and verify any C deps (vcpkg/CMake) are configured.
Wrong target triple
Use the MSVC host: x86_64-pc-windows-msvc. Switch if needed and rebuild in an x64 shell.
OpenSSL / native deps fail
Install build tools and SDK, then use vcpkg or prebuilt binaries. Ensure environment vars point to the right libs.
CMake not found
Install CMake (User or System) and reopen terminal so it’s on PATH. Some crates run CMake in build.rs.
Toolchain sanity check
- Compiler:
rustc --version, Cargo:cargo --version. - MSVC:
where cl.exe. If missing, install Build Tools. - SDKs: Confirm Windows 10/11 SDK in Visual Studio Installer.
- Shell: Always use an x64 Developer shell for x64 builds.
Switch to the MSVC host
If you installed the GNU toolchain by accident, switch to MSVC for best Windows compatibility.
- Install MSVC components via Visual Studio Build Tools.
- Ensure rustup default host is MSVC for x86_64.
- Reopen an x64 Developer shell and rebuild.
Clean reinstall (last resort)
- Uninstall rustup toolchains if corrupted.
- Reinstall Visual Studio Build Tools + Windows SDK.
- Re-run rustup-init.exe and accept defaults for MSVC.
- Open a fresh terminal and rebuild a sample project.
Next steps
- Revisit installation to verify every component.
- Plan packaging and signing in Package & Sign.