ATL Release Mode compile error: error LNK2001: unresolved external symbol _main

Posted on Updated on

Problem:
Build ATL project in debug mode, it’s okey. But in Release Mode, it shows the following message:

Compiling resources…
Linking...
Creating library ReleaseMinSize/BTBoxATL.lib and object ReleaseMinSize/BTBoxATL.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinSize/ABCATL.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

ABCATL.dll - 2 error(s), 0 warning(s)

Solution:

  1. remove the symbol _ATL_MIN_CRT from the release configurations
  2. or

  3. remove all dependencies on the C run-time library

Why ??
In ATL programming guild, developers shouldn’t use CRT functions. So, the atl wizard add the symbol _ATL_MIN_CRT to release mode configurations for the main reason, to reduce the size of executable, about 25K saved. _ATL_MIN_CRT symbol also solves the dependency on MSVCRT.dll problem without having to statically link CRT into executable.

廣告

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

您的留言將使用 WordPress.com 帳號。 登出 / 變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 / 變更 )

Facebook照片

您的留言將使用 Facebook 帳號。 登出 / 變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 / 變更 )

連結到 %s