VS 2015未解决的外部符号错误

the*_*rge 2 c++ c++11 visual-studio-2015

我的代码抛出了这个错误:

1>MSVCRTD.lib(exe_winmain.obj) : error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>C:\Users\thequantumforge\Desktop\scripts\Visual Studio 2013\Projects\newtonsmethod\x64\Debug\newtonsmethod.exe : fatal error LNK1120: 1 unresolved externals
Run Code Online (Sandbox Code Playgroud)

代码如下:

#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <cmath>
#include <cfloat>
#include <chrono>
using namespace std;
const long double h = LDBL_EPSILON;

long double equation(long double x) {
    return (pow(x, 3) - x + 1);
}

long double intercept(long double x) {
    // x_n+1 = xn - f(xn)/f'(xn)
    long double deriv = (equation(x + h) - equation(x)) / h;
    if (deriv == 0)
    {
        x += h;
        return (x - equation(x) / ((equation(x + h) - equation(x)) / h));
    }
    return (x - equation(x) / deriv);

int main() {...}
Run Code Online (Sandbox Code Playgroud)

它使用C++ 11编译器在Code :: Blocks中工作,所以我不确定为什么它不能与Visual Studio 2015一起工作.我试着查看其他答案,但这些都不清楚或者是其他版本的视觉工作室.我做了一些研究,发现它应该是由main()函数的拼写错误引起的,但似乎并非如此.我尝试先声明函数原型然后在main()之后定义它们,但结果是一样的.

Ser*_*sen 6

将您的解决方案更改为linker => system部分中的控制台应用程序:

在此输入图像描述