Unable to compile Rust hello world on Windows: linker link.exe not found
Solution 1:
I downloaded and installed the Build Tools for Visual Studio 2019. During installation I selected the C++ tools. It downloaded almost 5GB of data. I restarted the machine after installation and compiling the code worked fine:
> cargo run
Compiling helloworld v0.1.0 (C:\Users\DELL\helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 12.05s
Running `target\debug\helloworld.exe`
Hello, world!
Solution 2:
I had a similar issue "error: linking with link.exe failed: exit code: 1
"
To solve it, I did
rustup toolchain install stable-x86_64-pc-windows-gnu
then
rustup default stable-x86_64-pc-windows-gnu
and
cargo build
Compiling hello v0.1.0 (C:\Users\leke\dev\rust\hello)
Finished dev [unoptimized + debuginfo] target(s) in 1.66s