error LNK2019 please help

Okay, so apparently something in my code isn't linking correctly and I have no idea what it is. I've spent a day now researching how to fix this on my own and I am now coming to the C++ forums for help.

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef _CLASSES_H_
#define _CLASSES_H_

#include "AIE.h"
#include "math.h"

//class Vectors; 
//class Sprite; 

const int iScreenWidth = 1280;
const int iScreenHeight = 780; 


//vectors class
class Vectors{
public:
	Vectors();
	~Vectors(); 

protected:
	 //Struct for the vector points
	struct Point2D{
		float x; 
		float y; 
	};

	//Struct for the clickable objects in the menu
	struct ClickableObject{
		Point2D position; 
		int sprite; 
		int width;
		int height; 
	};

	//stuct for all the moving objects in the game
	struct MovableObject{
		Point2D position; 
		Point2D speed; 
		int sprite; 
		int width; 
		int height; 
	};

public:
	Point2D pointSubtract(Point2D &v, float s);
	Point2D pointAdd(Point2D &v, float s);
	Point2D multiplyScalar(Point2D &v, float s);
	Point2D pointSubtract(Point2D &v, Point2D &v2);
	Point2D pointAdd(Point2D &v, Point2D &v2);
	Point2D getNormal(Point2D &v);
	float getMagnitude(Point2D &v);
	 
	 
};



//Class for building Sprites
//class Sprite{
//public:
//	Sprite(); 
//	~Sprite(); 
//
//	
//	
//	friend class Vectors; 
//
//};




//Class with everything for the game inside
class Game: public Vectors{
public:
	Game();
	~Game(); 

	//size of the mouse sprite
	int mouseW; 
	int mouseH; 
	
	
	

	//Struct for the game setup 
	struct GameMenu{
		bool playGame; 
		bool gamePause; 
		bool gameOver; 
		bool escape; 
	};



	//size of the bullet sprites
	int bullets; 
	int bulletsH;
	int bulletsW;
	//player sprite size and if they died or not
	int playerOne; 
	int playerOneW; 
	int playerOneH;
	int playerOneScore; 
	bool playerOneDied; 

	//enemy sprite size and if they died or not 
	int enemyH; 
	int enemyW; 
	bool enemyDied; 

	//size of menu items
	int playGameButtonW; 
	int playGameButtonH; 
	int exitGameButtonW; 
	int exitGameButtonH; 

	//speed of variables
	float speed;
 
	//framecounter and hits
	int frameCounter; 
	int hits; 

	void setgame();
	unsigned int bgImage;

	//prototyping the gamesetup
	bool testOnScreen(MovableObject &obj);
	void updateBulletCollision (MovableObject &obj);
	bool checkBulletCollision (MovableObject &bullets, MovableObject &playerOne);
	bool checkCollision(MovableObject &obj1, MovableObject &obj2);
	void initMenu(ClickableObject &playGameButton, ClickableObject &exitGameButton, MovableObject &mouse);
	void drawMenu(ClickableObject &playGameButton, ClickableObject &exitGameButton);
	void updateMenu(unsigned int bgImage, MovableObject &mouse, MovableObject &enemy, ClickableObject &exitGameButton, ClickableObject &playGameButton, MovableObject &bullets, MovableObject &playerOne);
	void initGame(MovableObject &bullets, MovableObject &playerOne, MovableObject &enemy);
	void destroyGame(MovableObject &bullets, MovableObject &playerOne, MovableObject &enemy);
	void gameScore();
	void move(MovableObject &playerOne);
	void updateGame(MovableObject &playerOne);
	void drawGame(MovableObject &bullets, MovableObject &playerOne, MovableObject &enemy);

	//friend class Vectors; 
	
	
};



#endif 


So this is my "Classes.h" file

1
2
 
Error	3	error LNK2019: unresolved external symbol "public: __thiscall Vectors::Vectors(void)" (??0Vectors@@QAE@XZ) referenced in function "public: __thiscall Game::Game(void)" (??0Game@@QAE@XZ)	C:\Users\Student\documents\visual studio 2010\Projects\RetroGame2\RetroGame2\GameSetup.obj

I'm not quite done with the code yet, but I don't want to continue until I know it will run. So if anybody can help me out and maybe see something in my code that I've become blind to after staring at it for over a day now will be greatly appreciated.

I think it might be in one of my .cpp files so if there's nothing wrong with my classes I will post the .cpp file that they are being used in.
Last edited on
Yes you do need to post the .cpp file(s), that after all is what you're trying to compile.

Surely you're not trying to compile a header file? Where is the implementation of classes declared in your "Classes.h" file?

All you've got here are declarations, you've got to give the compiler something to work with.

Your linker error looks like you've tried to create a "Game" object without implementing the "Vector" class...
I just fixed it! Thank you for your reply. You are right. I made a Game object with everything inside being a vector object. Bone headed mistake. I'm in this fast paced programming class and we've only been in class for a month so I'm still struggling a little on the simple and obvious stuff, but thank you very much!
Topic archived. No new replies allowed.