Install Rust GNU toolchain on Windows

Install MSYS2

  • Download & Install: Download the installer from the official MSYS2 website and run it. Using the default installation path (e.g., C:\msys64) is highly recommended

pacman -Syu
pacman -S --needed base-devel mingw-w64-x86_64-toolchain

Set Up and Configure Rust

rustup target add x86_64-pc-windows-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup set default-host x86_64-pc-windows-gnu

Create (or edit) a file at %USERPROFILE%\.cargo\config.toml. Add these lines to explicitly tell Cargo which linker and archiver to use; replace C:\msys64 with your actual MSYS2 path if different

[target.x86_64-pc-windows-gnu]
linker = "C:\\msys64\\mingw64\\bin\\gcc.exe"
ar = "C:\\msys64\\mingw64\\bin\\ar.exe"