thequantumforge
thequantumforge

Reputation: 63

VS 2015 unresolved external symbol error

This error was thrown by my code:

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

The code is as follows:

#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() {...}

It worked in Code::Blocks using the C++11 compiler, so I'm not sure why it isn't working with Visual Studio 2015. I tried looking at other answers, but those were either unclear or were for other versions of Visual Studio. I did some research and found out that it's supposed to be caused by a misspelling of the main() function, but that doesn't seem to be the case. I tried declaring the function prototypes first then defining them after main(), but the result is the same.

Upvotes: 2

Views: 2900

Answers (1)

Serve Laurijssen
Serve Laurijssen

Reputation: 9763

Change your solution into a console application in the linker => system section:

enter image description here

Upvotes: 6

Related Questions