Irrlicht Tutorial help: LNK2019 + LNK2028

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
Arya
Posts: 12
Joined: Tue Oct 07, 2008 2:35 am

Irrlicht Tutorial help: LNK2019 + LNK2028

Post by Arya »

Hey guys,


I'm having a bit of trouble with the Irrlicht tutorial on this forum. Here is the code:

Code: Select all

#include <irrlicht.h>
#pragma comment(lib, Irrlicht.lib);



using namespace irr; 
using namespace core; 
using namespace scene; 
using namespace video; 
using namespace gui; 



int main() { 

 IrrlichtDevice* device = createDevice(EDT_OPENGL, core::dimension2d<s32>(640,480)); 
 IVideoDriver* video = device->getVideoDriver(); 
 ISceneManager* smgr = device->getSceneManager(); 

 while(device->run() && device) { 
  video->beginScene(true, true, video::SColor(255,0,0,255)); 
  smgr->drawAll(); 
  video->endScene(); 
 } 
} 
And here are the errors I'm getting:

Code: Select all

1>main.obj : error LNK2028: unresolved token (0A000530) "class irr::IrrlichtDevice * __cdecl irr::createDevice(enum irr::video::E_DRIVER_TYPE,class irr::core::dimension2d<int> const &,unsigned int,bool,bool,bool,class irr::IEventReceiver *)" (?createDevice@irr@@$$FYAPAVIrrlichtDevice@1@W4E_DRIVER_TYPE@video@1@ABV?$dimension2d@H@core@1@I_N22PAVIEventReceiver@1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)

1>main.obj : error LNK2019: unresolved external symbol "class irr::IrrlichtDevice * __cdecl irr::createDevice(enum irr::video::E_DRIVER_TYPE,class irr::core::dimension2d<int> const &,unsigned int,bool,bool,bool,class irr::IEventReceiver *)" (?createDevice@irr@@$$FYAPAVIrrlichtDevice@1@W4E_DRIVER_TYPE@video@1@ABV?$dimension2d@H@core@1@I_N22PAVIEventReceiver@1@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
Any ideas, guys?
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Post by Josh1billion »

Put quotes around Irrlicht.lib.

i.e., change..
#pragma comment(lib, Irrlicht.lib)
to
#pragma comment(lib, "Irrlicht.lib")
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
Arya
Posts: 12
Joined: Tue Oct 07, 2008 2:35 am

Post by Arya »

Thanks man, that dd the job 8)
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Post by Josh1billion »

You're welcome. :)
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
Arya
Posts: 12
Joined: Tue Oct 07, 2008 2:35 am

Post by Arya »

Just one more question about the tutorial. I'm trying to make a cube and see it:



Code: Select all

#pragma comment(lib, "Irrlicht.lib")


#include <irrlicht.h>


 using namespace irr; 
 using namespace core; 
 using namespace scene; 
 using namespace video; 
 using namespace gui; 

int main() { 

 IrrlichtDevice *device = createDevice(EDT_DIRECT3D9); 
 IVideoDriver* video = device->getVideoDriver(); 
 ISceneManager* smgr = device->getSceneManager(); 
 ISceneNode* cube = smgr->addCubeSceneNode();
 cube->setPosition(vector3df(0,0,5)); 
 ICameraSceneNode* cam = smgr->addCameraSceneNode();
 cam->setPosition(vector3df(0,0,4));

 while(device->run() && device) { 
  video->beginScene(true, true, video::SColor(55,0,0,255)); 
  smgr->drawAll(); 
  video->endScene(); 
 } 
} 

But all I see is a blank screen. Any help?[/code]
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Post by Josh1billion »

It looks like your cube is a little too close to the camera. I changed a line and compiled and it worked. The line you need to change is your cube->setPosition() line, change it to this:

Code: Select all

cube->setPosition(vector3df(0,0,50));
That should work fine; it does for me.

Also, another line you should add after setting the camera's position is this, although in this case it doesn't actually change the end result (in most cases it will):

Code: Select all

cam->setTarget(cube->getPosition());
That line will cause your camera to "look" at the cube's position (i.e., look at the cube). If you want the camera to keep looking at the cube throughout your game (assuming the cube is going to move around the screen at some point), you'll need to call that function frequently-- at least whenever the cube moves.

While we're at it, here's another line that won't change anything in this case, but it's good practice because it will matter in some cases as well-- call this somewhere after you set the camera's position:

Code: Select all

cam->setUpVector(vector3df(0, 1, 0));
What that does is tell the application which way the camera's "up vector" should point. An up vector is simply a vector going in the direction "up" from the object's position. Imagine if your head is the camera. Almost always, your "up vector" is going to be pointing toward the sky, hence a positive Y value in the code above (1). But in some rare situation where the camera should be tilted, you can set it to something else (say your camera is a first-person shooter type of camera from the player's eyes, and the player is dead and laying on his right cheek-- the top of the player's head, i.e. the camera's head, is no longer pointing to the sky, but is instead pointing to the right-- so you would set the up vector to (1, 0, 0) in the case).

I'm not entirely sure, but I don't think the particular values you use in an up vector matter so long as the value is positive/negative/zero as it should be, because I think it's all thought of in terms relative to the origin of (0,0,0). Ex: 1 and 1000 should have the same effect as each other. But I'm not 100% sure on this, being new to Irrlicht myself.
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
Arya
Posts: 12
Joined: Tue Oct 07, 2008 2:35 am

Post by Arya »

Wow man, thanks. I'll commit that to memory. :)
Josh1billion
Posts: 125
Joined: Thu Dec 11, 2008 9:50 pm
Location: Wisconsin
Contact:

Post by Josh1billion »

You're welcome again. :) I love to help people..
www.JoshForde.com

Latest release: Super Orbulite World.
In development: Season of Dreams and others
Post Reply