Nothing new: Msvcrt.dll
Yes! Making your executable working with Windows 2000 - 7. I need the compatibility for the Stoned infector. When you develop a program with Visual C++, it links it against "msvcrXX.dll", so your application depends on the availability of the runtime library. A clean solution is using WinSxS (side-by-side assembly, I have mentioned in a previous article), where your installer will put the required dll into the WinSxS directory and you define in a manifest the version you prefer.
However, if you want a small application running on every system without dll problems, you want to link your application against msvcrt.dll, the one available in all Windows systems since Windows NT and that works everywhere.
Peter Kleissner, Software Architect
Msvcrt.dll and Msvcr90.dll
Msvcrt.dll is platform (Windows) specific, on Windows 2000 it contains only the basic functions and on Windows Vista it will contain also the buffer security checks functions required for the new applications. Msvcrt.dll releases are always branches of the current up to date MsvcrXX.dll.
The solution: Smart, simple & easy
Microsoft does it with its files, and you can too. You simply get msvcrt.lib from the Windows 2000 DDK (or get it here, faster) and link your application against it. Because it contains only the basic functions, you will take msvcrt_win2000.obj from the Windows Driver Kit (the most up to date one) and include it in your application. That file contains the "difference" functions between the Windows 2000 msvcrt.dll and msvcr90.dll. Cool thing!
Required Visual Studio project settings: Linker -> Input: Ignoer All Default Libraries = Yes (/NODEFAULTLIB) Additional Dependencies: add msvcrt_.lib Put msvcrt.lib from Windows 2000 DDK in the project folder (where the solution file is) and rename it to msvcrt.lib You can either add msvcrt_win2000.obj from the latest Windows Driver Kit, or disable extended CRT functions: C++ -> Optimization Optimization = Full Optimization (/Ox) Enable Intrinsic Functions = No Favor Size Or Speed = Favor small code (/Os) C++ -> Code Generation Enable C++ Exceptions = No Runtime Library = Multi-threaded (/MT) (REQUIRED!) Buffer Security Check = No (/GS-) Enable Function-Level Linking = No (/Gy-)
Visual Studio maps "msvcrt.lib" automatically to your platform specific toolset (msvcrt90.lib) - thus the renaming.
- Dynamically linking with MSVCRT.DLL using Visual C++ 2005
- Building Tcl with the free VC++ toolkit
- Compiling Vim with Visual C++ 2003 Toolkit
- Under the Hood: Reduce EXE and DLL Size with LIBCTINY.LIB (Matt Pietrek)