Resource compiling error

I have just finished my first simple windows program, which should theoretically work. However, I get "fatal error RC1004: unexpected end of file found" on my resource header file.
After googling the error, I added a few lines to the end of the file (as suggested by the majority of sites I looked at). This however yeilded a linking error: "error LNK2019: unresolved external symbol".

Everything else compiles fine, and I am using Visual C++ 2008 Express
I was wondering if anyone knew how to fix this problem.
Cheers.
Can you post the resource file?
1
2
#define IDI_SKELETON		1000
#define IDI_SKELETON_SM		1001 
Try to add a newline at the end of file
( http://msdn.microsoft.com/en-us/library/ms932412.aspx )
Last edited on
Yeah I did that. That gave the "error LNK2019: unresolved external symbol " error I mentioned.
Could it be my compiler at fault?
That's strange... Can you post the whole code (including C++ sources) ?
Sure, here it is.
Also bear in mind that this is from a tutorial, so it's an almost exact replica (with a few naning differences and the addition of some notes) of a working program.

GameEngine.cpp:
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#include "GameEngine.h"

// Static Variable (aasigning a fixed pointer to game engine address)
GameEngine *GameEngine :: m_pGameEngine = NULL;
	/*	Pointer 'GameEngine' points to the global pointer 'm_pGameEngine' of class 'GameEngine',
		but doesn't point to an obj */

//The WinMain function handles window functions and methods, but is separate from Game Engine functions and methods
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
	MSG			msg;
	static int	iTickTrigger = 0;
	int			iTickCount;

	if (GameInitialise (hInstance) )
	{
//Initalise Game Engine
		if (!GameEngine :: GetEngine() -> Initialise (iCmdShow) )
			return FALSE;

//Enter the main message loop
		while (TRUE)
		{
			if (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE) )
			{
		//Message Processing
				if (msg . message == WM_QUIT)
					break;							//End loop if program recives windows quit message
				TranslateMessage (&msg);
				DispatchMessage (&msg);
			}
			else
			{
		//Check to see if the engine is active
				if (!GameEngine :: GetEngine() -> GetSleep() )
				{
			//Check tick count to see if a cycle has elapsed
					iTickCount = GetTickCount();
					if (iTickCount > iTickTrigger)
					{
						iTickTrigger = iTickCount + GameEngine :: GetEngine() -> GetFrameDelay();
						GameCycle();
					}
				}
			}
		}
		return (int) msg.wParam;
	}
	//End the game
	GameEnd();

	return TRUE;
}

LRESULT CALLBACK WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
//All messages sent to game engine
	return GameEngine :: GetEngine() -> HandleEvent (hWnd, msg, wParam, lParam);
}

//Constructors and Destructor Definition
GameEngine :: GameEngine (HINSTANCE hInstance, LPSTR szWindowClass, LPSTR szTitle, WORD wIcon,
						  WORD wSmallIcon, int iWidth, int iHeight)
{
	//Definition of game engine member varibles
	m_pGameEngine = this;
	m_hInstance = hInstance;
	m_hWindow = NULL;
	if (lstrlen (szWindowClass) > 0)
		lstrcpy (m_szWindowClass, szWindowClass);
	if (lstrlen (szTitle) > 0)
		lstrcpy (m_szTitle, szTitle);
	m_wIcon = wIcon;
	m_wSmallIcon = wSmallIcon;
	m_iWidth = iWidth;
	m_iHeight = iHeight;
	m_iFrameDelay = 50;			//Defines the time between frames as 50ms, i.e. 20fps
	m_bSleep = TRUE;
}

GameEngine :: ~GameEngine()
{
}

//General Methods
//Initialising the engine
BOOL GameEngine :: Initialise(int iCmdShow)
{
	WNDCLASSEX wndclass;

//Create the window class for the main window
	wndclass.cbSize			= sizeof (wndclass);
	wndclass.style			= CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc	= WndProc;
	wndclass.cbClsExtra		= 0;
	wndclass.cbWndExtra		= 0;
	wndclass.hInstance		= m_hInstance;
	wndclass.hIcon			= LoadIcon (m_hInstance, MAKEINTRESOURCE (GetIcon() ) );
	wndclass.hIconSm		= LoadIcon (m_hInstance, MAKEINTRESOURCE (GetSmallIcon() ) );
	wndclass.hCursor		= LoadCursor (NULL, IDC_ARROW);
	wndclass.hbrBackground	= (HBRUSH)(COLOR_WINDOW + 1);
	wndclass.lpszMenuName	= NULL;
	wndclass.lpszClassName	= m_szWindowClass;

//Regester the window class
	if (!RegisterClassEx (&wndclass) )
		return FALSE;

//Calculate window size and position, based upon game
	int iWindowWidth = m_iWidth + GetSystemMetrics (SM_CXFIXEDFRAME) * 2,
		iWindowHeight = m_iHeight + GetSystemMetrics (SM_CYFIXEDFRAME) *2 + GetSystemMetrics (SM_CYCAPTION);
	if (wndclass.lpszMenuName != NULL)
		iWindowHeight += GetSystemMetrics (SM_CYMENU);
	int iXWindowPos = (GetSystemMetrics (SM_CXSCREEN) - iWindowWidth) / 2,
		iYWindowPos = (GetSystemMetrics (SM_CYSCREEN) - iWindowHeight) /2;

//Create Window
	m_hWindow = CreateWindow (m_szWindowClass, m_szTitle, WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX,
		iXWindowPos, iYWindowPos, iWindowWidth, iWindowHeight, NULL, NULL, m_hInstance, NULL);
	if (!m_hWindow)
		return FALSE;

//Show and Update window
	ShowWindow (m_hWindow, iCmdShow);
	UpdateWindow (m_hWindow);

	return TRUE;
}

LRESULT GameEngine :: HandleEvent(HWND hWindow, UINT msg, WPARAM wParam, LPARAM lParam)
{
//Route windows messages to the game engine members
	switch (msg)
	{

//Set the game window and start the game
	case WM_CREATE:
		SetWindow (hWindow);
		GameStart (hWindow);
		return 0;

//Activate and deactivate the game and update the sleep status
	case WM_ACTIVATE:
		if (wParam != WA_INACTIVE)
		{
			GameActivate (hWindow);
			SetSleep (FALSE);
		}
		else
		{
			GameDeactivate (hWindow);
			SetSleep (TRUE);
		}
		return 0;

//Painting the game
	case WM_PAINT:
			HDC				hDC;
			PAINTSTRUCT		ps;
			hDC = BeginPaint (hWindow, &ps);

			GamePaint (hDC);

			EndPaint (hWindow, &ps);
			return 0;

//End game and close application
	case WM_DESTROY:
		GameEnd();
		PostQuitMessage (0);
		return 0;
	}
	return DefWindowProc (hWindow, msg, wParam, lParam);
}


GameEngine.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once	//Prevents rereferencing of the header file

#include <windows.h>

//Game engine function declarations
BOOL GameInitialise (HINSTANCE hInstance);
void GameStart (HWND hWindow);
void GameEnd();
void GameActivate (HWND hWindow);
void GameDeactivate (HWND hWindow);
void GamePaint (HDC hDC);
void GameCycle();

//Windows Function Declarations
int WINAPI			WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow);
LRESULT CALLBACK	WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

//GameEngine class
class GameEngine
{
protected:
	static GameEngine*	m_pGameEngine;
	HINSTANCE			m_hInstance;
	HWND				m_hWindow;
	TCHAR				m_szWindowClass[32];
	TCHAR				m_szTitle[32];
	WORD				m_wIcon, m_wSmallIcon;
	int					m_iWidth, m_iHeight;
	int					m_iFrameDelay;
	BOOL				m_bSleep;

public:
	//Constructor
	GameEngine (HINSTANCE hInstance, LPSTR szWindowClass, LPTSTR szTitle, WORD wIcon, WORD wSmallIcon,
				int iWidth = 1024, int iheight = 820);
	//Destructor
	virtual ~GameEngine();

	//General Methods
	static GameEngine*  GetEngine()						//Method for accessing the game engine pointer externally
		{
			return m_pGameEngine;
		};
	BOOL		Initialise(int iCmdShow);				//Used to initialise the program once the engine is created
	LRESULT		HandleEvent(HWND hWindow, UINT msg,		//Handles standard windows events within the engine
				WPARAM wParam, LPARAM lParam);

	//Member access Methods
	HINSTANCE	GetInstance()					{ return m_hInstance; };
	HWND		GetWindow()						{ return m_hWindow; };
	void		SetWindow(HWND hWindow)			{ m_hWindow = hWindow; };
	LPTSTR		GetTitle()						{ return m_szTitle; };
	WORD		GetIcon()						{ return m_wIcon; };
	WORD		GetSmallIcon()					{ return m_wSmallIcon; };
	int			GetWidth()						{ return m_iWidth; };
	int			GetHeight()						{ return m_iHeight; };
	int			GetFrameDelay()					{ return m_iFrameDelay; };				//Time between frames (ms)
	void		SetFrameRate(int iFrameRate)	{ m_iFrameDelay = 1000 / iFrameRate; };	//FPS
	BOOL		GetSleep()						{ return m_bSleep; };
	void		SetSleep(BOOL bSleep)			{ m_bSleep = bSleep; };
};


Hour3-Resource.h:
1
2
#define IDI_SKELETON		1000
#define IDI_SKELETON_SM		1001 


The post was too long so I'll include the main program below.
Here is the main program

Hour3-Skeleton.cpp:
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
#include "Hour3-Skeleton.h"

//Game engine functions
BOOL GameInitialise (HINSTANCE hInstance)
{
//Create the game engine
	_pGame = new GameEngine (hInstance, TEXT("Game Skeleton"), TEXT("Game Skeleton"), IDI_SKELETON, IDI_SKELETON_SM);
	if (_pGame == NULL)
		return FALSE;

//Set frame rate
	_pGame -> SetFrameRate (15);

	return TRUE;
}

void GameStart (HWND hWindow)
{
//Seed random number generator
	srand (GetTickCount() );
}

void GameEnd()
{
//Clean up the engine
	delete _pGame;
}

void GameActivate (HWND hWindow)
{
	HDC		hDC;
	RECT	rect;

//Draw Activation text on the game screen
	GetClientRect (hWindow, &rect);
	hDC = GetDC (hWindow);
	DrawText (hDC, TEXT("ACTIVATED"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
	ReleaseDC (hWindow, hDC);
}

void GameDeactivate (HWND hWindow)
{
	HDC		hDC;
	RECT	rect;

//Draw Deactivation text on the game screen
	GetClientRect (hWindow, &rect);
	hDC = GetDC (hWindow);
	DrawText (hDC, TEXT("DEACTIVATED"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
	ReleaseDC (hWindow, hDC);
}

void GAMEPAINT (HDC hDC)
{}

void GameCycle()
{
	HDC		hDC;
	HWND	hWindow = _pGame -> GetWindow();

//Draw the skeleton icon at random positions on the game screen
	hDC = GetDC (hWindow);
	DrawIcon (hDC, rand() % _pGame -> GetWidth(), rand() % _pGame -> GetHeight(),
		(HICON)(WORD) GetClassLong (hWindow, GCL_HICON) );
	ReleaseDC (hWindow, hDC);
}


Hour3-Skeleton.h:
1
2
3
4
5
6
7
#pragma once			//Prevents rereferencing of the header file

#include <windows.h>
#include "Hour3-Resource.h"
#include "GameEngine.h"

GameEngine* _pGame;		//Global Variable 


Hour3-Skeleton.rc:
1
2
3
4
#include "Hour3-Resource.h"

IDI_SKELETON	ICON	"Skeleton.ico"
IDI_SKELETON_SM	ICON	"Skeleton_sm.ico"


Cheers.
void GamePaint (HDC hDC); is not implemented.
I think
void GAMEPAINT (HDC hDC) {}
should be
void GamePaint (HDC hDC){}
That did it. Thak you very much. :)
I completely missed that, even after looking for hours.
Cheers.
Topic archived. No new replies allowed.