MSVC guide

Rust MSVC toolchain on Windows — Visual Studio Build Tools setup

The MSVC toolchain for Rust requires Visual Studio Build Tools 2022 with the "Desktop development with C++" workload. This provides link.exe, the Windows SDK and the UCRT. rustup installs them automatically when you choose the default Windows target.

MSVC toolchain — why Rust needs it on Windows

link.exe
The Microsoft linker. Rust uses it to link compiled object files into executables on Windows.
Windows SDK
Headers and libraries for Windows API calls. Required for any Windows-specific code.
UCRT
Universal C Runtime. Provides C standard library functions that Rust's stdlib depends on.
cl.exe
MSVC C++ compiler. Rust itself does not use it, but some build scripts (build.rs) need it.

Install MSVC Build Tools manually

  • 1

    Download Visual Studio Build Tools 2022

    Go to visualstudio.microsoft.com → scroll to "Tools for Visual Studio" → download Build Tools for Visual Studio 2022.

  • 2

    Select "Desktop development with C++"

    In the installer, check Desktop development with C++. The right-side panel shows what is included — make sure these are checked: MSVC v143, Windows 11 SDK, C++ CMake tools, Windows Universal CRT SDK.

  • 3

    Install and restart rustup

    After Build Tools install, run rustup toolchain install stable-x86_64-pc-windows-msvc in PowerShell to make sure the toolchain links to the new Build Tools.

Check MSVC toolchain is working

Developer PowerShell for VS 2022
# Check linker is available:
PS> link.exe /?
Microsoft (R) Incremental Linker Version 14.x
# Check Rust can find the toolchain:
PS> rustup show
active toolchain: stable-x86_64-pc-windows-msvc

MSVC toolchain questions

Do I need the full Visual Studio or just Build Tools?

Only the Build Tools for Visual Studio 2022 are needed — not the full IDE. The Build Tools are free, smaller (~4 GB vs ~10 GB) and provide everything Rust needs: the MSVC linker, Windows SDK and UCRT. If you already have Visual Studio 2019 or 2022 installed, Rust will use it automatically.

Can I use Visual Studio 2019 instead of 2022 for Rust?

Yes. Rust supports Visual Studio 2015, 2017, 2019 and 2022 on Windows. Visual Studio 2022 is recommended as it is the latest supported version. Specify a different toolchain version by setting the MSVC_TOOLSET_VERSION environment variable or configuring it in your cargo config.