Why does software install MS Visual C++ Runtime

Staples

Diamond Member
Oct 28, 2001
4,953
119
106
I have always wondered this. C++ code is fully compiled into machine language and NOT interpreted or compiled into byte code. Or at least that is what I have always been taught so why do some big applications need to install the VC++ runtime?
 

Red Squirrel

No Lifer
May 24, 2003
70,215
13,606
126
www.anyf.ca
VC++ is Microsoft's implementation of C++ and is not fully standard C++. Basically it's a specialized library that is needed to compile (and in some cases, run) programs made with it.

Personally I don't like using it as it creates an unnecessary dependency. For a large company, development time is more important than the end result, and vc++ / .net does make certain things easier and faster when developing so that's why it's often used.
 

mv2devnull

Golden Member
Apr 13, 2010
1,526
160
106
The runtime includes a dynamically linked library (DLL) that contains a lot of fully compiled machine language code that the application binaries link in rather than duplicating such code within their own binaries.

Red Squirrel said it much better and quicker.
 

Merad

Platinum Member
May 31, 2010
2,586
19
81
I have always wondered this. C++ code is fully compiled into machine language and NOT interpreted or compiled into byte code. Or at least that is what I have always been taught so why do some big applications need to install the VC++ runtime?

Well, you have the C++ (or C) programming language itself, and then you have libraries which add functionality for the language. C++ itself doesn't know or care what kind of system it's running on, so the language itself doesn't do anything that might be specific to one platform. Instead it defines libraries to do various things (say, printing text to the screen, or holding certain kinds of data), and while those libraries have the same interface, they are implemented differently depending on the platform where the code is running.

So at some point, the program needs access to the code that implements the library functions. This can be done by static linking (basically, when the program is compiled the library code is copied into the .exe file) or by dynamic linking (when the program runs, it tries to load the code from a .dll file). There are a variety of potential issues with static linking, so MS recommends (and most people use) dynamic linking on Windows.

Edit: To actually answer your original question about why they're always installed by programs... The original theory was that your programs would always automatically use the newest version of a DLL, but the problem is that it's very easy for updates to a DLL to change things and break backwards compatibility. So program 1 might be installed with version 0.1 of foo.dll, but then program 2 is installed with version 0.25 of foo.dll. Now program 1 crashes every time it tries to run, because it doesn't understand the new version of foo.dll. This was known as DLL Hell. Ultimately MS made it possible to have multiple versions of the same library installed. So now, your computer would have both version 0.1 and 0.25 of foo.dll, and each program just uses the appropriate version that it was compiled against.
 
Last edited:

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I have always wondered this. C++ code is fully compiled into machine language and NOT interpreted or compiled into byte code. Or at least that is what I have always been taught so why do some big applications need to install the VC++ runtime?

It's compiled but it's not statically compiled so that all of the dependencies are included in the binary.
The C++ runtime is a set of functions common to MS' implementation of C++ so any C++ app needs them. MS has failed pretty hard at library versioning over the years so most apps install the version they were built against just in case the one you have isn't 100% compatible.
 

Venix

Golden Member
Aug 22, 2002
1,084
3
81
VC++ is Microsoft's implementation of C++ and is not fully standard C++. Basically it's a specialized library that is needed to compile (and in some cases, run) programs made with it.

Personally I don't like using it as it creates an unnecessary dependency. For a large company, development time is more important than the end result, and vc++ / .net does make certain things easier and faster when developing so that's why it's often used.

Every complete C++ implementation provides a C++ runtime; what do you think GCC's libstdc++ is?

MSVC++ is no less "standard C++" than any other major compiler. Its C++ Standard compliance is excellent, on-par with GCC for C++03 support.
 

lambchops511

Senior member
Apr 12, 2005
659
0
0
Every complete C++ implementation provides a C++ runtime; what do you think GCC's libstdc++ is?

MSVC++ is no less "standard C++" than any other major compiler. Its C++ Standard compliance is excellent, on-par with GCC for C++03 support.

Same problem with linux, only except gcc is a pain in the ass to get libstdc++ to compile statically.
 

lambchops511

Senior member
Apr 12, 2005
659
0
0
Static compile is sometimes the only option when you don't have root access to the cluster of machines you want to run your binary off of.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Static compile is sometimes the only option when you don't have root access to the cluster of machines you want to run your binary off of.

You don't need to statically compile for that, you can just include a copy of the library and use the LD_PRELOAD variable to include your copy.

Or you can just link against whatever C++ library is already present on the cluster, which would be the preferred method I would think.
 

cytg111

Lifer
Mar 17, 2008
25,731
15,211
136
you could always go c89 as it depends on the msvsrt.dll that has been shipped with the os since win2k