Reputation: 713
After installing First time rust on ubuntu try to run this program.
fn main() {
println!("Hello, world!");
}
Error:
$ cargo run
Compiling test1 v0.1.0 (/home/saad/Documents/Rust/test1)
error: linker `cc` not found
|
= note: No such file or directory (os error 2)
error: aborting due to previous error
error: could not compile `test1`.
Upvotes: 32
Views: 21218
Reputation: 3108
This error happens mostly either linux or wsl. You can fix it by running the following command :
sudo apt install build-essential
If still issue persists, please go on to install gcc
as below
sudo apt-get install gcc
If gcc
ended with some error, please go on with the following command also (This is purely optional only)
apt-get update --fix-missing
Upvotes: 5
Reputation: 713
As mentioned in the message, the linker 'cc' is missing.
You can install it using apt-get
:
sudo apt-get install gcc
After the installation completes, the problem should be solved.
Upvotes: 38
Reputation: 3252
Your system is missing a C linker, which Rustup assumes that you already have. You can install one (among other potentially useful tools, like make) via the following command:
sudo apt install build-essential
Upvotes: 9