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

NAIEM picture NAIEM · Jul 8, 2011 · Viewed 237.9k times · Source

While I am running the simple code as below I have two errors as following:

#include <iostream>
#include <string>
using namespace::std;

template <class Type>
class Stack
{
public:
    Stack (int max):stack(new Type[max]), top(-1), maxsize(max){}
    ~Stack (void) {delete []stack;}
    void Push (Type &val);
    void Pop (void) {if (top>=0) --top;}
    Type& Top (void) {return stack[top];}
    //friend ostream& operator<< (ostream&, Stack&);
private:
    Type *stack;
    int top;
    const int maxSize;
};

template <class Type>
void Stack <Type>:: Push (Type &val)
{
    if (top+1<maxsize)
        stack [++top]=val;
}

Errors:

MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

What Should I do?

Answer

Bohdan picture Bohdan · Dec 16, 2011

Thats a linker problem.

Try to change Properties -> Linker -> System -> SubSystem (in Visual Studio).

from Windows (/SUBSYSTEM:WINDOWS) to Console (/SUBSYSTEM:CONSOLE)

This one helped me