2

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.

asked Feb 9, 2016 at 14:06
3

1 Answer 1

6

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

enter image description here

answered Feb 9, 2016 at 14:13
Sign up to request clarification or add additional context in comments.

2 Comments

Where can I find this? I cannot find it in any of the options sections.
Found it under 'Project'. Thanks!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.