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
How to Make Cmake Output into a 'Bin' Dir
Where Exactly Does C++ Standard Say Dereferencing an Uninitialized Pointer Is Undefined Behavior
What Exactly Is the "Immediate Context" Mentioned in the C++11 Standard For Which Sfinae Applies
Is the Return Type Part of the Function Signature
Std::String to Float or Double
Output Unicode to Console Using C++, in Windows
Is Std::Vector or Boost::Vector Thread Safe
How to Use a Custom Deleter With a Std::Unique_Ptr Member
Detecting Superfluous #Includes in C/C++
Examples of When a Bitwise Swap() Is a Bad Idea
Replace Substring With Another Substring C++
How to Link C++ Program With Boost Using Cmake
Why Will Std::Sort Crash If the Comparison Function Is Not as Operator ≪