Why can not define _ATL_MIN_CRT in Service Project?
-
I create a new Windows Service Project. I find there is not _ATL_MIN_CRT in both Unicode Release build configuration. I think it is weird so I added _ATL_MIN_CRT in them. Then building action failed with message "unresolved external symbol _main". why can not define _ATL_MIN_CRT in Win32 Service Project?:doh:
-
I create a new Windows Service Project. I find there is not _ATL_MIN_CRT in both Unicode Release build configuration. I think it is weird so I added _ATL_MIN_CRT in them. Then building action failed with message "unresolved external symbol _main". why can not define _ATL_MIN_CRT in Win32 Service Project?:doh:
Look at the documentation:
MSDN wrote:
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.What that says is that your service is using C run-time library functions that rely on having the C run-time startup code. Possibly
malloc
(maybe vianew
?).