Fix "error: linker link.exe not found"
This means the MSVC linker is not on PATH. Fix:
- 1
Install Visual Studio Build Tools 2022
Download from visualstudio.microsoft.com. Select Desktop development with C++.
- 2
Reinstall the Rust toolchain
PS> rustup toolchain uninstall stable-x86_64-pc-windows-msvcPS> rustup toolchain install stable-x86_64-pc-windows-msvc
Fix "LNK2019: unresolved external symbol"
This means a function is declared but the library that implements it is not linked. Common fixes:
- Add the missing feature flag to your
windowscrate dependency inCargo.toml - Add a
#[link(name = "library")]attribute or add tobuild.rs:println!("cargo:rustc-link-lib=library"); - Ensure the Windows SDK is installed (check in Visual Studio Installer)
Fix "LNK1181: cannot open input file"
The linker cannot find a .lib file. This usually means:
- The Windows SDK component providing that .lib is not installed
- The library path is not in
LIBenvironment variable - A build.rs script is referencing a library that does not exist on your system
Linker error questions
Rust linker error after Visual Studio update
Visual Studio updates sometimes change the MSVC toolset version. Run rustup toolchain install stable to re-link rustup to the new MSVC version. If errors persist, open "Visual Studio Installer" and click Modify on Build Tools 2022 — verify the C++ components are still installed.
How to use GNU linker instead of MSVC on Windows?
Switch to the GNU toolchain: rustup default stable-x86_64-pc-windows-gnu. This requires MSYS2 with mingw-w64-x86_64-gcc. The GNU toolchain is less compatible with Windows-specific crates like windows-rs.