Monday, September 21, 2009

using the old msvcrt runtime with visual studio 2005

If you are trying to run an .exe built with vs2005 on other than the box you built it with you might get an error saying that msvcrt80.dll is missing. This is because msvcrt.lib points you to the multithreaded import library for MSVCR7/8/90.DLL.

Microsoft says this about msvcrt.dll:
The msvcrt.dll is now a "known DLL," meaning that it is a system component owned and built by Windows. It is intended for future use only by system-level components. (and their own software like windbg)

Here's the breakout of which libraries cause which runtime dll to be imported:
e.g. MSVCRT.LIB == MSVCRT.DLL with Visual Studio 5/6, MSVCR7.DLL with Visual Studio 2002/2003 and MSVCR80/90.DLL with Visual Studio 2005/2008.

Well it goes in the face of logic to force someone to carry around all these DLLS. So the solution is to build one that relies on the lowest common denominator: MSVCRT.DLL

The trick to ensuring that your .exe uses this dll is by using the MSVCRT.LIB that comes with the DDK. Add this line to your Property Pages->Linker->General->Additional Library Directories
"C:\WINDDK\6001.18001\lib\crt\i386" -or- whereever your DDK is installed
You also need to link with msvcrt_win2000.obj

Now clean and recompile. You should now be able to run your exe on any box without the missing DLL error. (Assuming you don't use some feature that is _ONLY_ in the more modern DLL)

No comments:

Post a Comment