tags:

views:

802

answers:

3

I frequently come across Windows programs that bundle in MSVCRT (or their more current equivalents) with the program executables. On a typical PC, I would find many copies of the same .DLL's. My understanding is that MSVCRT is the C runtime library, somewhat analogous to glibc/libc.so under *nix.

Why do Windows programs have to bring along their C libraries with them, instead of just sharing the system-wide libc?


Update: thanks to Shog9, I started to read about SxS, which has further opened up my eyes to the DLL linkage issues (DLL Hell) - http://blogs.gotdotnet.com/martynl/archive/2005/10/13/480880.aspx is one useful intro to the issue...

+1  A: 

Programs are linked against a specific version of the runtime, and that required version is not guaranteed to exist on the target machine. Also, matching up versions used to be problematic.

In the Windows world, it's very bad manners to expect your users to go out and find and install a separate library to use your application. You make sure any dependencies not part of the host system are included with your app.

In the linux world this isn't always as simple, since there's a much larger variation for how the host system might look.

Joel Coehoorn
+3  A: 

Short answer? Because, up until SxS, MSVCRT was not reliably versioned! Can you imagine the madness that would result if programs compiled and tested against libc 5 would silently start using libc 6? That's the situation we were in for many years on Windows. Most of us would just as soon never again trust MS with keeping breaking changes out of a version

Shog9
SxS doesn't guarantee you are going to use the same version you compiled against either :( default is to follow policy, and default policy is to automatically upgrade.
Greg Domjan
+4  A: 

[I'm the current maintainer of the Native SxS technology at Microsoft]

New versions of MSVCRT are released with new versions of Visual Studio, and reflect changes to the C++ toolset. So that programs compiled with versions of VS released after a particular version of Windows continue can work downlevel (such as VS 2008 projects on Windows XP), the MSVCRT is redistributable, so it can be installed there.

CRT installation drops the libraries into %windir%\winsxs\, which is a global system location, requiring administrator privileges to do so.

Since some programs do not want to ship with an installer, or do not want the user to need administrator privileges on the machine to run their installer, they bundle the CRT directly in the same directory as the application, for private use. So on a typical machine, you'll find many programs that have opted for this solution.

Eugene Talagrand