Using _ATL_MIN_CRT in Your ATL Project
Two goals you might hope to achieve when you use ATL are:
- Minimizing your image size
- Minimizing 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.
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.
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:
- Recognizing Functions that Rely on CRT Startup Code
- Identifying CRT Startup Code Dependencies by Building