The executable needs a dll

Why? A someone told about bare metal..

VCRUNTIME140.DLL

The problem is fixed. The question is not.. :slight_smile:

Are referring to this earlier thread that has been closed?

What question is still unanswered?

Why does my executable seek a dll? I heard rust executables have ability to run on bare metal.

By using only the core Rust libraries you can develop for bare metal, for creating an OS for example. But otherwise, if you're using the std library, you need an OS, which means you need the services of that OS (which I assume includes that DLL on windows).

See:

4 Likes

AFAIK only the *-musl targets statically link libc. You can however tell other targets to statically link libc with crt-static (see the links at the bottom of the SO answer for more information).

3 Likes

dll is a Windows thing and Windows is definitely NOT bare metal. (and btw, the vcruntime140.dll dependency is a xxx-windows-msvc thing specifically, you will not need it for xxx-windows-gnu target)

rust uses the system linker, and thus the system C library, so it can guarantee seemless interop with C code. by default the microsoft Visual C++ compiler (a.k.a. msvc) links the C runtime library dynamically, so that's also the default behavior in rust.

as already mentioned, you can tell rust to link the C runtime statically, but if your program also links any C libraries, you must ensure they are all built with the same libc variant. to quote microsoft's documentation:

All modules passed to a given invocation of the linker must have been compiled with the same runtime library compiler option (/MD, /MT, /LD).

saying "rust has the ability to run on bare metal" is like saying "rust supports XYZ operating system", it does NOT mean your Windows program can run on non-Windows operating systems, or without any operating systems at all.

also, rust is NOT an interpreter, "rust supports bare metal" simply means you can write programs for bare metal targets using the rust language, it does NOT mean every rust program is bare metal.

2 Likes

Thank you.very much. I got it.
It was strange for me to watch my executable does not want to start on my new notebook.

The vcruntime*.dll libraries are runtime libraries which are provided as part of the Microsoft Visual C++ Redistributable packages. They are called "Redistributable" because these packages are explicitly intended for application developers to bundle them with their installer and install them when installing their program. VCRUNTIME140.DLL in particular should be installable using https://aka.ms/vs/17/release/vc_redist.x64.exe according to Latest supported Visual C++ Redistributable downloads | Microsoft Learn.

1 Like