[WHATEVER]: https://www.reddit.com/r/rust/comments/197zxwx/rust_and_msys2_on_windows/, userComment: NishantD2D [WHATEVER]: https://stackoverflow.com/questions/21196525/rust-installation-on-windows/68835925#68835925
I do not have MSYS2 but just standard MinGW64 installation. But that shouldn't matter much
- First download and run rustup application
- Choose 2nd choice : Manually install the pre-requisite
- Press 'y' to continue
- Define 'host triple' :
x86_64-pc-windows-gnu
- Default toolchain : stable
- Profile : default
- Modify PATH variable (y/n) : y
Then just press enter and let the installation complete.
Now find the cargo installation in C:\Users{User_Name}.cargo
Open this folder in an editor like VSCode and create a new file "config" without any extension and add the following commands in it :
[target.x86_64-pc-windows-gnu]
linker = "C:\\{mingw installation path}\\bin\\gcc.exe"
ar = "C:\\{mingw installation path}\\bin\\ar.exe"
By default the path must be : "C\Msys2\mingw64"
That's it, now you can use Rust with GCC.
Note : Install mingw with Msys2 (mingw-toolchain + base devel) because rust-analyzer (VSCode extension for Rust) will require the tools to compile the cargo directory. If you install only MinGW without Msys2, you'll be able to compile the code using CodeRunner (VSCode extension for executing languages) command but debugging would not work.