Thread: unresolved externals?!?!

  1. #1
    Registered User
    Join Date
    Feb 2008

    unresolved externals?!?!

    I keep getting the error messages
    Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib
    Error 2 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\Projects\Assignment3MJB\Debug\Assignment3MJB. exe 1

    I have absolutely no idea what they mean, please help.
    This is my code so far
    using namespace std;
    void input(char employee[100][100], int hours[7][100], float payrolldata[100][100], double&& r, int&& l, int&& d);
    int main()
    	char employee[100][100];
    	int hours[7][100];
    	float payrolldata[100][100];
    	double r;
    	int l=0;
    	int d=0;
    	input(employee, hours, payrolldata, r, l, d);
    	return 0;
    void input(char employee[100][100], int hours[7][100], float payrolldata[100][100], double&& r, int&& l, int&& d)
    	char tempname[100];
    	int l, d, m, t, w, h, f, s, u;
    	cout <<"Hello, Please enter the following information for the Payroll Report." <<endl;
    	cout << "Name: ";
    	cin.get(tempname, 30, '\n');
    	strcpy(employee[y], tempname);
    	cout << endl << "Hours worked per day: ";
    	cin >> m >> t >> w >> h >> f >> s >> u;
    	hours[0][y] = m;
    	hours[1][y] = t;
    	hours[2][y] = w;
    	hours[3][y] = h;
    	hours[4][y] = f;
    	hours[5][y] = s;
    	hours[6][y] = u;
    	cout << endl << "Pay rate:";
    	cin >> r;
    	cout << endl << "Dependents: ";
    	cin >> d;
    	cout << endl << "Health(y/n): ";
    	cin >> l;

  2. #2
    Registered User
    Join Date
    Jun 2007
    Could it be your file you are editing is not in your project? i.e. Right click your Project->Add Existing Item->(select your .cpp that you are showing us)

    I could be way off, but just another thing to try.
    Last edited by HyperShadow; 02-27-2008 at 10:33 PM.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    The assembly startup code may be looking for this main. I'm using MSVS 2005 under a win32 console project and this is the main function it wants.

    int _tmain(int argc, _TCHAR* argv[])
    	return 0;
    Notice the error:

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    no it actually is looking for _main which is linker name for main

    What I get when trying to compile:
    Error	1	error C2143: syntax error : missing ')' before '&&'
    I also do not get this && thing where the reference should be
    After I fixed it - I got another errors like undeclared vars, mredeclared arguments etc.

    So how you get to linking without fixing these errors?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  5. #5
    Registered User
    Join Date
    Jun 2007
    yah like i said I don't think he actually added the file to his project

    1: Create a new Console project
    2: Add a new blank .cpp to the project.
    3: Goto File->New File->.cpp and copy his code into this file (note: it won't be in the project, but it will be in the IDE making you think its in the project)
    4: Build the project.

    then one should replicate his problem.

  6. #6
    Join Date
    Oct 2007
    Inside my computer
    Not necessary. You can just right-click project -> add -> existing file.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Unresolved Externals
    By nickname_changed in forum C++ Programming
    Replies: 10
    Last Post: 08-31-2003, 06:13 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM