unresolved externals?!?!

This is a discussion on unresolved externals?!?! within the C++ Programming forums, part of the General Programming Boards category; I keep getting the error messages Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib and ...

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    12

    unresolved externals?!?!

    I keep getting the error messages
    Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup MSVCRTD.lib
    and
    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
    Code:
    #include<iostream>
    #include<iomanip>
    #include<string>
    #include<cmath>
    #include<fstream>
    #include<stdio.h>
    #include<cctype>
    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
    Posts
    41
    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
    Posts
    9,598
    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.

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

  4. #4
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    no it actually is looking for _main which is linker name for main

    What I get when trying to compile:
    Code:
    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?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  5. #5
    Registered User
    Join Date
    Jun 2007
    Posts
    41
    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
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,007
    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, 01: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, 07:13 PM
  5. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21