Hello I'm new in rust, a few month ago I was learning rust and everything it's fine when I compiling rust file but after few weeks I want to continues my learning I'm getting error when compiling file rust.
I'm using ubuntu 20.04
rust version : rustc 1.71.0 (8ede3aae2 2023-07-12)
have installed gcc and build-essential
The error is telling you that you're missing a linker, which is a required component of building Rust code.
It's been a little while since I've used ubuntu, but try installing the gcc package (which contains a linker IIRC) with sudo apt get install gcc and then rebuilding your Rust project.
That brings up a question: why is OP calling rustc directly, rather than cargo? For a beginner, or Indeed anyone who needs help building a project, this is almost certainly the wrong thing to do. Rust is not C, and rustc is not gcc or llvm.
The better way to proceed is to create a cargo project, eg:
cargo new --lib my-project
cd my-project
Then navigate to `my-project/src/lib.rs, add the code there, and execute at a bash/cmd/PS prompt: