If you are a programmer for WIN32 API, following error
would have given you lots of headaches. When you are compiling a simple
application with either one of the following functions as your main() function,
this error can be occured.
- WinMain
- wWinMain
- main
- wmain
When you are compiling such a program with Visual Studio,
you may get the following
error.error LNK2019: unresolved external symbol wmain referenced in function mainWCRTStartup corelibc.lib
error.error LNK2019: unresolved external symbol wmain referenced in function mainWCRTStartup corelibc.lib
What this error reflects is that the wmain function cannot
be found by the compiler. The CRT entrypoint for your application needs to
match your "main" entrypoint. Here is the mapping:
- WinMain -> WinMainCRTStartup
- wWinMain -> wWinMainCRTStartup
- main -> mainACRTStartup
- wmain -> mainWCRTStartup
The entrypoint is specified on the linker command line after
the /ENTRY option. Sometimes the linker can guess which is the right
entrypoint to use, but I would never trust it and just always specify.
Go to the properties->Configuration Properties->Linker->Command
Line->
In the Additional options section, just add the following
line
/ENTRY:"WinMainCRTStartup" ( If you are using
WinMain )
Like that you can add the relevant option for matching main
function you are using.
THAT'S IT !!!!!!!!!!!!!!!!
I have faced the same problem.
ReplyDeleteHow can I fix that?
what do you mean by saying "use wmain instead of main"
Thanks
@NM: Just rename the "main" method of your application as "wmain". That's It.
ReplyDelete