Error Lnk2019: Unresolved External Symbol _Winmain@16 Referenced in Function _Tmaincrtstartup

LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

You put your WinMain into a C++ namespace. WinMain() has to be a free function in the global namespace, not in your application namespace.

Error: Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

Set your sub system to console instead of windows, or add the winmain function as your entry point.

See: http://msdn.microsoft.com/en-us/library/fcc1zstk.aspx

And:

difference between Console (/SUBSYSTEM:CONSOLE) and Windows (/SUBSYSTEM:WINDOWS)

help with error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

main is a special function in C++ - it cannot be a template. And if it could be, how would you provide the type(s) it is templated on? I think maybe you don't quite understand templates yet.

I have just checked this by creating a VC++ console project with a main that looks like this:

template <typename T>
int main() {}

and I get exactly the link error message you get, but no compilation error (which there should be).

Build Error LNK2019: unresolved external symbol _WinMain@16

Project properties -> C/C++ -> Linker -> System -> SubSystem: Console (/SUBSYSTEM:CONSOLE)

If you want a console project.



Related Topics



Leave a reply



Submit