Linker Error - LNK2005

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

Linker Error - LNK2005

Post by AlexL »

I've just started to add in a menu system for my mini-project. I'm using the IEvent code from '5.UserInterface' though when I go to compile I get two errors with the linker. I've posted my IEvent code and the resaults from the compile below. Any help on this matter would be greatful.

Code: Select all

IrrlichtDevice *device = 0; //Place Holder
...
class eventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{
		if (event.EventType == EET_GUI_EVENT)
		{
			s32 id = event.GUIEvent.Caller -> getID();
			IGUIEnvironment* guienv = device -> getGUIEnvironment();

			switch(event.GUIEvent.EventType)
			{
			case EGET_BUTTON_CLICKED:
				if (id == 101)
				{
					//Finish Later
				}

				break;
			}
		}
		return false;
	}
};
--------------------Configuration: RB - Win32 Debug--------------------
Compiling...
main.cpp
rb_game.cpp
Linking...
rb_game.obj : error LNK2005: "class irr::IrrlichtDevice * device" (?device@@3PAVIrrlichtDevice@irr@@A) already defined in main.obj
Debug/RB.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.

RollerBall.exe - 2 error(s), 0 warning(s)
Though if I am to take out the place holder device, I get these errors.
--------------------Configuration: RB - Win32 Debug--------------------
Compiling...
main.cpp
.\rb_game.h(44) : error C2065: 'device' : undeclared identifier
.\rb_game.h(44) : error C2227: left of '->getGUIEnvironment' must point to class/struct/union
rb_game.cpp
.\rb_game.h(44) : error C2065: 'device' : undeclared identifier
.\rb_game.h(44) : error C2227: left of '->getGUIEnvironment' must point to class/struct/union
Error executing cl.exe.

RB.exe - 4 error(s), 0 warning(s)
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

Don't need this.........

IGUIEnvironment* guienv = device -> getGUIEnvironment();
Programmer of the Irrlicht Scene Editor:
Homepage - Forum Thread
Version 2 on its way!!
AlexL
Posts: 184
Joined: Tue Mar 02, 2004 6:06 pm
Location: Washington State

Post by AlexL »

Thanks for the help Whoppy, it worked :D Now on to finishing the project
Post Reply