"already defined on Main.obj"

I'm creating a text-based RPG, but I have been recieving this error:
1
2
3
4
5
1
1>  PlayerHouse.cpp
1>PlayerHouse.obj : error LNK2005: "public: void __thiscall PLAYER::SetAge(int)" (?SetAge@PLAYER@@QAEXH@Z) already defined in Main.obj
1>PlayerHouse.obj : error LNK2005: "public: int __thiscall PLAYER::GetAge(void)" (?GetAge@PLAYER@@QAEHXZ) already defined in Main.obj
1>C:\Archivos de programa\Lawedan Computer, Inc\Medieval Life\Debug\Medieval Life.exe : fatal error LNK1169: one or more multiply defined symbols found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


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
45
46
47
48
49
50
51
52
53
54
55
// main.cpp
#include "Library.h"

#define VERSION "0.0.1"

void main()
{
	// MAIN FILE
	cout << "Medieval Life v."<<VERSION<<endl;
	cout << "(C) Lawedan Computer, Inc. All Rights Reserved"<<endl;

	cout << "Press Any Key To Continue"<<endl;
	cin.get();

	PlayerHouse_Bedroom_WakeUp();
}
//Global.h
#ifndef GLOBAL_DEFINE
#define GLOBAL_DEFINE
#endif

void PlayerHouse_Bedroom_WakeUp();
//Library.h
#include <iostream>
using namespace std;
#include "Global.h"
#include "Player.h"
//Player.h
class PLAYER{
private:
	int age;
	int money;
public:
	void SetAge(int newage);
	int GetAge();
};


void PLAYER::SetAge(int newage)
{
	age = newage;
}

int PLAYER::GetAge()
{
	return age;
}
//PlayerHouse.cpp
#include "Library.h"

PLAYER player;

void PlayerHouse_Bedroom_WakeUp()
{
}


Any ideas?
Kind Regards,

Matthew
closed account (zb0S216C)
Here's a few question you need to answer:
1) What IDE are you using?
2) What type of library are you trying to link?

If you're using Visual C++ Express 2010, and you're trying to link a static library, you can follow my instructions in a previous thread[1].

References:
[1]http://www.cplusplus.com/forum/general/43787/

Wazzak
Last edited on
Thanks for the fast answer.
I'm using Visual C++ Express 2010, the headers are already inside the solution and the project.
Kind Regards,

Matthew
You have function definitions inside a header file, but not in the class itsself, specifically SetAge and GetAge. Either move them into the class, or put them in a cpp file.
Thanks kev, your answer helped me, now I fixed the problem.
Thanks to everyone.
Topic archived. No new replies allowed.