Error during compile. LNK1120

Jun 10, 2014 at 6:08am
So I'm stuck unable to compile this program because it throws two errors. I'm not to completely sure what they are and don't seem to be the actual code but I'm a student and of course I could be wrong. Any help would be appreciated. I am using Visual Studio 2013 Ultimate BTW. Here is the code.

this is gatheringInfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "personalInfo.h"
#include <iostream>

using namespace std;

int main()
{
	int age = 1, day = 1, month = 1, year = 1989;
	string name = "Frank Navarrete";
	personalInformationClass PIC(age,day,month,year, name);

	cout << PIC.getAge();
	cout << age;
	return 0;
}


and this is persoanalInfo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <string>

typedef struct
{
	int day;
	int month;
	int year;
} DOBTEMP;


class personalInformationClass {
private:
	int age;
	DOBTEMP DOB;
	std::string name = "";
	std::string comments = "No Comments";
public:
	personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, std::string NAME)
	{
		age = AGE;
		populateDOB(DAY, MONTH, YEAR);
		name = NAME;
	}
	personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, std::string NAME, std::string COMMENTS)
	{
		age = AGE;
		populateDOB(DAY, MONTH, YEAR);
		comments = COMMENTS;
	}

	void populateDOB(int D, int M, int Y)
	{
		DOB.day = D;
		DOB.month = M;
		DOB.year = Y;
	}

	int getAge()
	{
		return age;
	}
};


and the errors
Error	1	error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup	C:\Users\Frank\documents\visual studio 2013\Projects\Info Database\Info Database\MSVCRTD.lib(crtexew.obj)	Info Database
Error	2	error LNK1120: 1 unresolved externals	C:\Users\Frank\documents\visual studio 2013\Projects\Info Database\Debug\Info Database.exe	Info Database


ANY advice would be helpful! cheers!
Last edited on Jun 10, 2014 at 6:16am
Jun 10, 2014 at 6:20am
Strip the personalInformationClass:: from lines 22 and 30. Does that make a difference?


Compiler converts source code into object files. The errors are from linker. The linker combines object files into a binary.
Last edited on Jun 10, 2014 at 6:21am
Jun 10, 2014 at 6:23am
You're right i guess it wouldn't.
How can i go about fixing the linker errors?
Last edited on Jun 10, 2014 at 6:40am
Jun 10, 2014 at 7:55am
GCC compiler doesn't like the personalInformationClass:: either
$ g++ -std=c++11 -Wall -Wextra -pedantic personalInfo.cpp -o personalInfo
In file included from personalInfo.cpp:1:0:
personalInfo.h:18:2: error: extra qualification ‘personalInformationClass::’ on member ‘personalInformationClass’ [-fpermissive]
  personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, std::string NAME)
  ^
personalInfo.h:24:2: error: extra qualification ‘personalInformationClass::’ on member ‘personalInformationClass’ [-fpermissive]
  personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, std::string NAME, std::string COMMENTS)
  ^
personalInfo.h:24:2: warning: unused parameter ‘NAME’ [-Wunused-parameter]

Without them, it compiles.
Jun 10, 2014 at 8:28am
Hippiewho wrote:
and the errors
That's a typical error when you choose the wrong project type. Make sure that it the project type is console
Jun 11, 2014 at 12:01pm
error LNK2019: unresolved external symbol
error LNK1120: 1 unresolved externals
the error is on line 1 gatheringInfo.cpp
#include "personalInfo.h"
should be
#include "persoanalInfo.h"
after you got errors on lines 15 and 16 "persoanalInfo.h"
1
2
std::string name = "";
	std::string comments = "No Comments"

propose to do
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include <string>
using namespace std;

typedef struct
{
	int day;
	int month;
	int year;
} DOBTEMP;


class personalInformationClass {
private:
	int age;
	DOBTEMP DOB;
	string name ;
	string comments;
public:
	personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, string NAME)
	{
		age = AGE;
		populateDOB(DAY, MONTH, YEAR);
		getline (cin, NAME);
	}
	personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, string NAME, string COMMENTS)
	{
		age = AGE;
		populateDOB(DAY, MONTH, YEAR);
		getline(cin, COMMENTS);
	}

	void populateDOB(int D, int M, int Y)
	{
		DOB.day = D;
		DOB.month = M;
		DOB.year = Y;
	}

	int getAge()
	{
		return age;
	}
};
Last edited on Jun 11, 2014 at 12:16pm
Jun 11, 2014 at 12:32pm
GCC compiler doesn't like the personalInformationClass:: either
Like keskiverto suggested:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <string>

typedef struct
{
	int day;
	int month;
	int year;
} DOBTEMP;


class personalInformationClass {
private:
	int age;
	DOBTEMP DOB;
	std::string name = "";
	std::string comments = "No Comments";
public:
	personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, std::string NAME)
	{
		age = AGE;
		populateDOB(DAY, MONTH, YEAR);
		name = NAME;
	}
	personalInformationClass::personalInformationClass(int AGE, int MONTH, int DAY, int YEAR, std::string NAME, std::string COMMENTS)
	{
		age = AGE;
		populateDOB(DAY, MONTH, YEAR);
		comments = COMMENTS;
	}

	void populateDOB(int D, int M, int Y)
	{
		DOB.day = D;
		DOB.month = M;
		DOB.year = Y;
	}

	int getAge()
	{
		return age;
	}
};
Jun 11, 2014 at 5:17pm
Sorry for the late reply. Had finals. So apparently i did choose the wrong project type. Fixed IT! Thanks for all the input guys ill take into account all that was said
Topic archived. No new replies allowed.