What does Rust need from C/C++ tools on Windows and Linux?

Hello everyone.
I am learning Rust and at present I am using Windows 10 platform but will be moving over to Linux OS or Mac OS soon. I use VS-Code on all platforms with Rust extensions.
My question is not about building/modifying the Rust compiler itself.
I am only interested in developing and debugging Rust applications and Rust libraries/crates.

I am trying to learn and understand what exactly does Rust bin & lib crate developer require from the base OS and C/C++ prerequisites (linker, compilers, C/C++ dependent libraries, etc).

On Windows it is documented that I must install Microsoft C/C++ tools and C++ redistributable.
I see this is several Gigabytes of exe/dll. Does Rust really need all of that of C/C++ baggage?
Is there some sort of minimum sub-set that Rust requires?
Perhaps I can just install MS link.exe, for example and dependent C/C++ libraries?

Also this - when I move to Linux OS for Rust development (or Mac OS?), what do I need to install for Rust development/debugging there as a minimum sub-set?

many thanks in advance

On Debian Linux I have worked with Rust with noting more than installing Rust with Rust up https://www.rust-lang.org/tools/install and using vim for editing.

For a little luxury I also use VS Code everywhere.

On Windows 10 I only ever use Rust with the Windows Subsystem for Linux running Debian. No Microsoft C++ tool required at all.

1 Like


Alas, Rust fails to install on WSL1, I tried it, got error, found this:

I was planning to try Windows 10 WSL but after WSL2 ships ib Windows 10, which is due this month, May 2020. The current WSL (1.0) has major performance issues that WSL2 promises to resolve.
I hope the above Rust install is fixed somehow. Rust installs OK on a Linux VM.

On Linux OS side (WSL or separate VM) - what Linux features do I need to enable or install for Rust to compile and to be able to use the VS-Code debugger with Rust?

It does? Nobody ever told me and I have never felt that anything was slow.

WSL 1 has been working very well for a long time now. The only issue is that there is no actual Linux Linux Underneath (Talk about Truth In Advertising) so I have had occasional annoyances when I want to do something that needs one, like generating core dumps or using perf tools.

I think I had to "apt-get install curl" before the rust up install command would work.

I only have "rust-analyser" installed to VSCode. Never did get Rust-RLS to work, complains the server crashes all the time, no clue why.

Over the decades I have almost never used a debugger in any language. Often I have found that when I do reach for a debugger in desperation it does not help as it hides the bug I'm looking for!

With all the checking that Rust does and the convenience it offers for writing/running tests I have yet to feel the need for a debugger in Rust.

do I need to install LLVM/CLANG or LLDB or anything else (libc etc) from the llvm.org or another web site since Rust uses LLVM ?
This question is for both Windows and for Linux (and Mac) OS.

To install Rust on Debian in WSL, in Debian servers, in Raspbian on the Raspberry Pi and in Ubuntu on the Nvidia Jetson Nano I have never done more than use rustup as directed by this page:https://www.rust-lang.org/tools/install

Don't over think it, just do it.

I did manage to install Rust for Windows 10 itself. But never got anything compiled as dependent libraries always seemed to be missing/unfound. e.g. openssl. Luckily I don't need to develop for Windows which is always a complicate and unpleasant experience.

thanks, Rust on Windows 10 is working well for me,
but I want to understand what Rust actually needs from Windows (and Linux) because MS VC++ Tools is a fat 2-3 GB installation which must be mostly redundant for Rust.
I also did not install LLVM on Windows for Rust, so perhaps it has the LLVM components inside Rust installation.... Pure speculation on my part! Likewise, if it depends on any C or C++ libraries, perhaps they are packaged in?

  • Rust needs a linker, and VS C++ tools have one. Nowadays there's semi-hidden option of using lld linker shipped with Rust, but that is not the default yet.

  • Rust needs a C runtime library to link to. I'm not sure if it would be enough to rely on just the msvcrt redistributable packages (they're probably just the dll versions, not static lib versions).

  • Windows-specific crates may want to link with Windows' system libraries, and Rust needs files from Windows SDK for this.

  • Any dependencies that use C libraries will likely want a working C compiler.

BTW: on Linux, including WSL, you may need to install build-essential package too.

1 Like

Many thanks!

So I do not need to install llvm or lldb or clang on any OS to compile and debug Rust ?

What components do I need installed (Linux and Windows) to get the Rust source code debugger working in VS-Code ? I have MS VC++ Tools and Rust VS-Code debugger is working for me but many variables are not visible as "optimized out" and it all seems to work "by magic"! 8^) LOL

If I am asking things that are documented - can you share a pointer to all that?

Much obliged!

You don't need to install llvm package. Rust has its own LLVM. But it needs a linker and system libraries from either gcc or clang or Visual Studio installation.

On Windows last time I checked the option in the Visual Studio installer was called "Windows 8 SDK". Probably "C/C++ build tools" or something like that too.

lldb is not required to compile Rust. Of course if you actually want to debug, then you'll need some debugger. For variables to be not optimized out, build in debug mode. Adding to Cargo.toml [profile.release] debug = true might help, but not as much as lowering optimization level.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.