tutorial 04 movement

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
aoos
Posts: 5
Joined: Sat Oct 06, 2007 3:08 pm

tutorial 04 movement

Post by aoos »

hi, i'm new to irrlicht. and i'd like to ask something about the 04 movement tutorial.
i saw that in the main.cpp theres a class MyEventReceiver and tried to put it in another file and include it to the main so i can free space in the main.cpp file. but when i try to bult it the compiler gives me error about node:
( 'node' : undeclared identifier). it may be that IsceneNode and IrrlichtDevice are not configured properly for this change. so how can i solve this error? thanks!
Cristiano87
Posts: 13
Joined: Wed Oct 03, 2007 9:00 am
Location: Milano, Italia

Post by Cristiano87 »

put

Code: Select all

extern scene::ISceneNode* node;
at top of myeventreceiver class prototype
aoos
Posts: 5
Joined: Sat Oct 06, 2007 3:08 pm

Post by aoos »

i try this but now i get a linker error:

error LNK2001: unresolved external symbol "class irr::scene::ISceneNode * node" (?node@@3PAVISceneNode@scene@irr@@A)
error LNK2001: unresolved external symbol "class irr::IrrlichtDevice * device" (?device@@3PAVIrrlichtDevice@irr@@A)
Cristiano87
Posts: 13
Joined: Wed Oct 03, 2007 9:00 am
Location: Milano, Italia

Post by Cristiano87 »

include irrlicht.h in that file
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

no, this are linker errors, so he probably forgot to link against the lib or he's linking against the wrong lib... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

No, the problem is you forgot to define the variables device and node that he has declared extern. In a .cpp file somewhere you need to write

Code: Select all

irr::IrrlichtDevice* device = 0;
irr::scene::ISceneNode* node = 0;
Now that you know what your problem is, you should _really_ avoid global variables if you can. They can cause lots of headaches.

If you insist on using globals, you should really give them names that are more unique so that you realize that you are using the globals and not a local variable with the same name. Often people prepend a g_ to the variable name to signify that it is a global.

Travis
aoos
Posts: 5
Joined: Sat Oct 06, 2007 3:08 pm

Post by aoos »

Thanks vitek! that was the problem it is running perfectly now thanks!
Post Reply