Why Rust language required to install g++ /visual c++/Gcc additionally for compiling rust file

why rust language required to install G++/Gcc/Visual c++ separately before installing rust while other system programming language like go /nim / don't need it and ready to use after installing.

If rust required G++/Gcc dependence why it is not installed along side with Rust or is it because to avoid complexity while installing rust in different platform

The Rust toolchain indeeds works without the g++ binary installed. What made you think you need so?

I've had Rust (rustc, cargo, and associated tools) installed on my Mac laptop for years. AFAIK I don't have either G++ or Visual C++ installed.

Rust file will not complied will out g++/gcc

Mac may already have clang compiler for object c

If you're running on Windows, Rust currently requires a third-party linker. As far as I'm aware, it doesn't need the C/C++ compiler, just the linker, but you generally end up installing the whole package because that's how the linker is distributed.

I haven't really looked into the dependencies on other platforms. I believe Linux just uses the system linker, which I end up installing on all my Linux systems, so I've never had Rust fail to work there.

Of course it does. But that wasn't either the subject of your thread or what you asked in your initial post.

Rust needs C compiler because rustc cannot compile C code when one uses C libraries.

1 Like

What makes you say this? Can you show us what you're trying to do?

sorry it will compile but it will not give output file since it is missing linker which is the part of gcc/g++
Rust use linker of c/c++ compiler which can be gcc/g++/clang/visual c++ or any other

To answer your question about Go and Nim, Go implemented their own from scratch in Go, and nim transpiles to C where it'll then use your system's C compiler and linker. So either nim requires a linker to be installed already or it'll include one in the installer for use just with nim code.

It sounds like you'll need to install a linker.

I personally use LLVM's linker, lld, via clang but any C compiler should be able to do the job.

while installing other language like go / nim / v it is not required it may have llvm's linker or any other solutions for it . but while install rust you wand it separately if your system do not have any of this compiler it will result in error. i feel that this will create a little confusion while installing on different operating system. it will be nice if llvm's linker /g++ compiler {open source} install along with rust installation process.

golang tends to avoid system dependencies and uses custom tooling for pretty much everything. Rust is designed to be more compatible with the C ecosystem, and reuses more of C libraries.

Specifically, nobody has written a pure-Rust linker yet, so Rust uses a C linker.

3 Likes

There is a long-term project to ship and use LLVM’s LLD linker by default on platforms where it is ready, maybe starting with a subset of Linux platforms. This will reduce the need to install a separate C toolchain.

4 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.