Instructions for setting up Rust on Windows, depending on your architecture.
- AMD64 (x86_64) — standard Intel/AMD processors
- ARM64 (AArch64) — Snapdragon/Qualcomm ARM-based Windows devices
Instructions for setting up Rust on Windows, depending on your architecture.
winget install Microsoft.VisualStudio.2022.BuildTools --override "--quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended"Restart your PC after installation.
Download and run rustup from https://rustup.rs/ or use winget:
winget install Rustlang.RustupRustup will automatically select the stable-x86_64-pc-windows-msvc toolchain.
Git Bash ships /usr/bin/link (a coreutils hard-link tool) which shadows MSVC's link.exe. Cargo will fail with:
link: extra operand '...'
Fix by prepending the MSVC tools directory to PATH in ~/.bashrc:
# Prepend MSVC tools so link.exe resolves to MSVC linker, not /usr/bin/link
for _msvc_dir in "/c/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/"*/bin/Hostx64/x64; do
[ -d "$_msvc_dir" ] && export PATH="$_msvc_dir:$PATH" && break
done
unset _msvc_dirThe glob pattern handles MSVC version changes automatically.
Restart your terminal, then verify:
$ which link
/c/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/linkrustc --version
cargo --version
cargo new test-project
cd test-project
cargo build --release
./target/release/test-project.exeOutput should be: Hello, world!
# Create a new project
cargo new myproject
cd myproject
# Development builds
cargo build
cargo run
# Release builds
cargo build --release
./target/release/myproject.exeInstall VS Build Tools + Rust via winget, fix the Git Bash linker conflict in ~/.bashrc, and cargo build works out of the box.
Running cargo build on Windows ARM64 fails with:
error: linker `rust-lld-link` not found
This happens because Rust defaults to aarch64-pc-windows-msvc which requires MSVC ARM64 libraries that aren't installed by default.
Build for x86_64 and let Windows ARM64 run binaries through emulation. This works transparently and is fine for development.
Download and run rustup from https://rustup.rs/ or use winget:
winget install Rustlang.Rustuprustup default stable-x86_64-pc-windows-msvc --force-non-hostcargo new test-project
cd test-project
cargo build --release
./target/release/test-project.exeOutput should be: Hello, world!
# Create a new project
cargo new myproject
cd myproject
# Development builds
cargo build
cargo run
# Release builds
cargo build --release
# The binary is x86_64 but runs on ARM64 via emulation
./target/release/myproject.exe$ rustup show
Default host: x86_64-pc-windows-msvc
installed toolchains
--------------------
stable-aarch64-pc-windows-msvc
stable-x86_64-pc-windows-msvc (active, default)Successfully built and tested:
For release builds targeting native ARM64, use GitHub Actions. GitHub's windows-latest runners have full Visual Studio with ARM64 tooling pre-installed.
Example workflow:
name: Release
on:
push:
tags:
- "v*"
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-pc-windows-msvc
- run: cargo build --release --target aarch64-pc-windows-msvc
- uses: softprops/action-gh-release@v2
with:
files: target/aarch64-pc-windows-msvc/release/*.exeUse x86_64 target for local development, GitHub Actions for release builds targeting ARM64.