Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Visual C++ runtime library - what for?

Tags:

c++

msvcrt

What's in MS Visual C++ runtime library? I mean, I googled it, and I always found things like help, app xxxx gives me MS Visual C++ runtime library error, with no explanation.

I thought that Windows C runtime libraries come with Windows? Not with VC++? Thanks.

EDIT: First, thanks for answers. I thing now I have bad idea of runtime libraries in windows. I mean, the first part, that Windows internally has its win32 API and so, that's OK, I knew it. Also, that Win32API are from kernel and user parts.

But I always thought that functions like GDI are accessed as DLL (which I still believe they are). But I thought even functions like printf and so are in some windows file.

So, am I right, when I know get it that "simple" functions like printf need to be linked directly and than use only Kernel part of OS directly, and more sophisticated Windows API functions are linked as dlls, therefore ARE NOT distributed with compiler but with OS? And they subsequently access Kernel?

I mean, lets say GDI, I tell it to draw picture, it makes all the hard work in user mode and than call kernel function which puts it all in framebuffer?

And last thought, why is this even solved this way? I mean, if VC++ runtime is just layer between C and WinAPI, why cant VC++ call directly WinAPI?

like image 910
B.Gen.Jack.O.Neill Avatar asked Nov 17 '10 22:11

B.Gen.Jack.O.Neill


People also ask

What is Microsoft Visual C used for?

Microsoft Visual C++ is a integrated development environment (IDE) used to create Windows applications in the C, C++, and C++/CLI programming languages.

What is Microsoft C runtime library?

The C runtime Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C standard library. The Visual C++ libraries that implement the CRT support native code development, and both mixed native and managed code. All versions of the CRT support multi-threaded development.

Do I need Microsoft Visual C on my computer?

We don't recommend that you delete any Visual C++ redistributable, because doing so could make multiple applications on your computer stop working. Given how little space they take up and how broadly they are used, it doesn't seem worth the hassle to mess with your current ecosystem of standard library files.

Should I remove Microsoft Visual C++?

Of course, the answer is yes. Since the MSVC package is required by many applications and games that are developed using the Microsoft Visual Studio runtime library. That is to say, certain programs like Python, Word Cloud, and Logitech may not function properly once the MSVC package is removed or corrupted.


1 Answers

This is an oversimplification, but it will give you the gist. The MSVCRT is a set of DLLs that implements parts of the C++ language. Functions like printf, memcpy and the like are implemented in these DLLs.

Every program that is compiled with a particular compiler and dynamically linked to the C++ runtimes must somehow have the correct version of the CRT binaries on the target machine. As a result, applications that ship to end users are often (usually?) also shipped with a package of these DLLs. This package is called a "redistributable" (or "redist"), and there is a different one for every combination of exact compiler version and target platform. For example, there are seperate and distinct redists for each of the following:

  • MSVC 10, 64-bit windows
  • MSVC 10, 32-bit windows
  • MSVC9, 64-bit windows
  • MSVC9 SP1, 64-bit windows

et cetera.

Yes, Windows usually "comes with" some version of the CRT. However, it comes with the version(s) that it needs in order to run the apps that shipped with Windows. If Windows and all it's apps were compiled in MSVC8 SP2 and your app is compiled in MSVC10, the CRT you require won't be present on the box simply because it's running Windows.

This is why its common practice to ship apps along with redists.

EDIT:

By way of Houdini like magic, I predict your next question will be "where do I get the redists?"

The answer is, from MicroSoft. Try a google search for "msvc 9 x64 redist" and you will find:

http://www.microsoft.com/downloads/en/details.aspx?familyid=bd2a6171-e2d6-4230-b809-9a8d7548c1b6&displaylang=en

like image 72
John Dibling Avatar answered Sep 22 '22 14:09

John Dibling