Using _ATL_MIN_CRT in Your ATL Project
Two advantages of ATL are that it allows you to:
Minimize your image size
Minimize your reliance on run-time DLLs
However, you might want to take advantage of some functions provided by the CRT. Because statically linking increases your image size, and dynamically linking ties you to the run-time DLL, using the CRT may deprive you of these key goals for using ATL.
To help solve this dilemma, ATL provides a solution: the _ATL_MIN_CRT macro. The _ATL_MIN_CRT macro, activated by setting the General Property option Minimize CRT Use in ATL to Yes, provides alternative implementations for many of the common CRT functions that would otherwise require the CRT startup code.
Console applications do not support _ATL_MIN_CRT. If you use _ATL_MIN_CRT in an ATL console application, you will receive link error "LNK2005: __osplatform already defined in atlmincrt.lib(atlinit.obj)."
Remember that using the _ATL_MIN_CRT macro does not guarantee that no functions from the CRT will be required.
If you use a function that requires the CRT startup code to operate properly, you will get the following linker error:
LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main
Providing your own implementation of _main does not solve this problem: you must either remove reliance on the functions that require the CRT startup code, or you must either statically link the startup code in your image or dynamically link to the CRT.
When _ATL_MIN_CRT is used without the /GS- compiler option, ATL headers will require the static CRT library. For more information, see.
For more information on linking to the CRT, see Linking to the CRT in Your ATL Project.
To identify the CRT startup code, see the following topics: