- Install target mingw-w64:
brew install mingw-w64 - Add target to rustup:
rustup target add x86_64-pc-windows-gnu - Create .cargo/config
- Add the instructions below to
.cargo/config
[target.x86_64-pc-windows-gnu]
linker = "x86_64-w64-mingw32-gcc"
- Fix cert
cp -f /usr/local/Cellar/mingw-w64/7.0.0_1/toolchain-x86_64/x86_64-w64-mingw32/lib/{,dll}crt2.o `rustc --print sysroot`/lib/rustlib/x86_64-pc-windows-gnu/lib
- And finally, run:
cargo build --target=x86_64-pc-windows-gnu --verbose
Useful commands: rustup show rustup target list
Super helpful! Thank you.