Troubleshooting

Fix Rust build errors on Windows — MSVC linker & toolchain guide

Most Rust build errors on Windows fall into three categories: missing linker (link.exe not found), missing MSVC components (Windows SDK or UCRT not installed), or architecture mismatch (32-bit vs 64-bit target conflict).

Fix linker errors on Windows

"error: linker link.exe not found"
MSVC Build Tools not installed or wrong PATH
Install Visual Studio Build Tools 2022 with Desktop development with C++
"LINK: fatal error LNK1181: cannot open input file"
Missing .lib file — dependency not linking correctly
Check features flags in Cargo.toml; verify Windows SDK is installed
"error LNK2019: unresolved external symbol"
Function declared but not linked — missing library
Add the required windows-rs feature or link the correct system library

Check your Rust environment

PowerShell
# Full environment check:
PS> rustup show
Default host: x86_64-pc-windows-msvc
active toolchain: stable-x86_64-pc-windows-msvc (default)
# Check MSVC linker is available:
PS> where.exe link.exe
C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.x\bin\...\link.exe
# Verbose build output:
PS> cargo build -vv 2>&1 | Select-String "error|warning"

Other common build errors on Windows

"cc.exe not found" in build.rs
A build script requires a C compiler
Install MSVC or set CC=cl.exe in environment
Cargo.lock conflict or dependency version mismatch
Multiple versions of a crate conflict
cargo update to resolve; cargo tree to inspect
proc-macro crate fails to compile
Architecture mismatch or missing rustc_private features
Use stable toolchain; avoid nightly-only proc-macro features
"permission denied" when building
Windows file lock — another process has the file
Close IDE or antivirus holding the file; re-run cargo build

Clean and rebuild from scratch

PowerShell
# Delete build artifacts:
PS> cargo clean
# Rebuild fresh:
PS> cargo build
# Reinstall toolchain if corrupted:
PS> rustup toolchain uninstall stable
PS> rustup toolchain install stable

Troubleshooting questions

Rust compiles on Linux but fails on Windows

Check for platform-specific code: Unix-only APIs (fork, epoll, POSIX paths), crates that do not support Windows, or path separators. Use cargo build --target x86_64-pc-windows-msvc and read errors carefully. The cfg attributes #[cfg(windows)] and #[cfg(unix)] let you write platform-specific branches.

cargo build hangs on Windows

Most likely Windows Defender scanning build artifacts. Add the project target directory to Defender exclusions. Also check Task Manager — if MsMpEng.exe (Defender) is at 100% CPU, exclusions will fix it.