Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to compile Rust hello world on Windows: linker link.exe not found

I have installed Rust on windows from Rust installation page. After installation I tried running the "hello world" program but got the following error.

>cargo run 

Error

Compiling helloworld v0.1.0 (C:\Users\DELL\helloworld)  error: linker `link.exe` not found note: The system cannot find the file specified. (os error 2) note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that VS 2013, VS 2015 or VS 2017 was installed with the Visual C++ option error: aborting due to previous error error: Could not compile `helloworld`.  To learn more, run the command again with --verbose. 

Code:

fn main() {     println!("Hello, world!"); } 
like image 426
Zobia Kanwal Avatar asked Apr 10 '19 00:04

Zobia Kanwal


People also ask

What is link EXE?

LINK.exe links Common Object File Format (COFF) object files and libraries to create an executable (.exe) file or a dynamic-link library (DLL).


1 Answers

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! 
like image 122
Zobia Kanwal Avatar answered Sep 19 '22 10:09

Zobia Kanwal