Last Modification: January 28, 2000

Why does my ATL project fail to build in release configuration? It gives me "error LNK2001: unresolved external symbol _main" linker error.

By default the ATL wizard creates all release configurations with the symbol _ATL_MIN_CRT in the preprocessor definitions. This instructs the linker to strip off the CRT startup code from the output image thus saving about 25K of code. This is in complete accordance with the ATL's main goal of producing the leanest possible executable. For the ATL programmaers this means they shouldn't use most CRT functions. This also solves the dependency on MSVCRT.DLL problems without having to statically link the CRT into the executable image. 

The problem arises when the programmer doesn't diligently follow this guideline and uses functions from the CRT which require the startup code. This includes any global scope class instances with non-empty constructors, the C++ exceptions, the FP operations, most CRT functions, etc. To revert to the normal dependency on the CRT, remove the symbol _ATL_MIN_CRT from the release configurations you'll use. The other solution is to remove all dependencies on the C run-time library.

References and samples: