Rust windows 使用mingw64出现link.exe 错误

302 阅读1分钟

这是msys2中的gcc安装部分:

pacman -S mingw-w64-x86_64-gcc

然后将%MSYS 安装路径%\mingw64\bin 添加到系统变量 PATH 中。 之后运行rust会报错:

note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017, VS 2019 or VS 2022 was installed with the Visual C++ option

解决方式:

rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu

应该可以了,还不行就先卸载

rustup uninstall toolchain stable-x86_64-pc-windows-msvc