Question:
LNK 2019 : Unresolved Externals Error?
2011-02-25 22:33:16 UTC
Ok, I'm about 2 seconds from taking a machine gun and spraying down my entire damned house.

I'm writing a big project currently, and am getting an error from code I thought was correct. So I started a new project and wrote some very simple code, to test out some basic class functions. I am fkn getting LNK2019 errors in this tiny code!!! I've dealt with this error before, and understand that it usually involves a missing #include, or that the program is told to call a function it can't find. My brain must be completely fried, so I need someone to tell me what the hell is wrong here.

HEADER FILE

#ifndef _Account_h_
#define _Account_h_

class Account
{
private:
int number;
double balance;
public:
Account(); // Constructor
void setAccount(int,double);
};

Account::Account()
{
number = 0;
balance = 0.0;
}

#endif


CPP FILE

#include "Account.h"
#include

using namespace std;

int main(void)
{
Account acct; // create object of the Account class

int number;
double balance;

cout<<"Account: ";
cin>>number;
cout<<"Balance: ";
cin>>balance;

acct.setAccount(number,balance); // Pass values to set

}
void Account::setAccount(int num, double bal)
{
number = num;
balance = bal;
}



And that's it. Theres this simple code that performs one function, and i'm getting this error. I've went over it 200 times, and am ready to stab things.

FYI: Kudos to any of you programmers, I can't stand this crap, it makes me more angry than anything i've ever done in my life.

Oh yeah, here is the exact error message I'm receiving:


1>MSVCRTD.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
1>C:\Users\JamesLaptop\Documents\Visual Studio 2008\Projects\Scratch3\Debug\Scratch3.exe : fatal error LNK1120: 1 unresolved externals
Three answers:
SteffenL
2011-03-04 12:24:26 UTC
First of all, main() is used in console applications. Please check the error again:

unresolved external symbol _WinMain...



WinMain is used in GUI applications. Maybe you wanted a console application, but it thinks you're trying to make a GUI application and thus it cannot find the WinMain function.



I tried your code just now when the subsystem was set to Console. Copy-pasted, and it compiled right away.



Then I changed the subsystem to Windows, and I got the same error as you! :)



So.. The solution here is to either use WinMain if you want to make a GUI application, or change the subsystem to Console.



You can find the setting here when viewing your project's properties: Linker > System > SubSystem
2016-10-17 02:26:31 UTC
hey there, I spoke back your previous question, that's basically an area, winmain is bearing on the optimum() function, you have an area between 'significant' and '()' so that's giving an errors, attempt removing the gap and compiling it.
justme
2011-02-26 06:58:51 UTC
you are doing a C++ application and it is puking about your main function.

try using this as your main:



int main(int argc, char* argv[])



instead of:



int main(void)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...