c++ - 错误 LNK2019 : unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

标签 c++ visual-studio visual-c++

当我运行下面的简单代码时,我有两个错误如下:

#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;
}

错误:

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

我该怎么办?

最佳答案

这是一个链接器问题。

尝试更改属性 -> 链接器 -> 系统 -> 子系统(在 Visual Studio 中)。

Windows (/SUBSYSTEM:WINDOWS)控制台 (/SUBSYSTEM:CONSOLE)

This one helped me

关于c++ - 错误 LNK2019 : unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6626397/

相关文章:

c++ - 从 debugdiag 分析时 CreateErrorInfo 上的内存泄漏?

c++ - 在 CMake 中找不到带有 'include_directories' 的 header

c++ - 二维矩阵的推送和弹出操作并在 C++ 中显示它们

c++ - QTreeView选择清除文本颜色

c++ - 'Excel.exe' 的调试信息找不到或不匹配

c# - 是否有一种方法可以在选择其他语言时获得自定义控件在VS编辑器中显示正确的语言

c# - 如何将 PublicKeyToken 解析为类? (连载问题)

c++ - 多次包含头文件c++

qt - 使用 Visual Studio 和 Qt 5.3 创建 QML 应用程序时退出时崩溃

c++ - C++ 中具有默认值的函数的引用参数