Pointer Linker error

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
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Pointer Linker error

Post by jimmythepage »

Hi forum...

I've got this problem:

when i build the project i have

fps_gamelevel.obj : error LNK2001: unresolved external symbol "public: class irr::scene::ISceneManager * __thiscall fps_manager::getSceneManager(void)" (?getSceneManager@fps_manager@@QAEPAVISceneManager@scene@irr@@XZ)
Fps-Release\Fps-Game.exe : fatal error LNK1120: 1 unresolved externals


a linker error!!!

it not find the pointer or something similar...

the important piece of code is:

Code: Select all

bool fps_gamelevel::loadlevel(fps_manager* p_manager,const irr::c8 *meshname, irr::core::vector3df position)
{
	
	m_plevelmesh = p_manager->getSceneManager()->getMesh(meshname);
	m_plevelnode = 0;
	
	if (m_plevelmesh)
		m_plevelnode = p_manager->getSceneManager()->addOctTreeSceneNode(m_plevelmesh->getMesh(0));
	m_plevelselector = 0;
	
	if (m_plevelnode)
	{		
		m_plevelnode->setPosition(position);

		m_plevelselector = p_manager->getSceneManager()->createOctTreeTriangleSelector(
            m_plevelmesh->getMesh(0), m_plevelnode, 128);
		m_plevelnode->setTriangleSelector(m_plevelselector);
		m_plevelselector->drop();
	}
	flag=true;
	return flag;
};
and

Code: Select all

#include "fps_manager.h"	


//! Costruttore
fps_manager::fps_manager()
{
	CreateDevice();
	Init();
}

//! Distruttore
fps_manager::~fps_manager()
{
}


//! Crea il device e prende gli altri puntatori fondamentali
void fps_manager::CreateDevice()
{	 
	m_pDevice=createDevice(EDT_DIRECT3D9,
		core::dimension2d<s32>(640, 480), 32, false, false, true, 0);

	m_pDriver = m_pDevice->getVideoDriver();
    m_pSceneManager = m_pDevice->getSceneManager();
	m_pGUIEnvironment = m_pDevice->getGUIEnvironment();
}

//! Ritorna un puntatore al device 
inline IrrlichtDevice* fps_manager::getDevice()
{
	return m_pDevice;
}

//! Ritorna un puntatore al driver 
inline IVideoDriver* fps_manager::getDriver()
{
	return m_pDriver;
}

//! Ritorna un puntatore allo SceneManager
inline ISceneManager* fps_manager::getSceneManager()
{
	return m_pSceneManager;
}

//! Ritorna un puntatore al GuiEnvironment
IGUIEnvironment* fps_manager::getGUIEnvironment()
{
	return m_pGUIEnvironment;
}


//! Inizializzazione del manager
void fps_manager::Init()
{
	this->getDriver();
};
tnx a lot to anyone help me....
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

in addition:

if i try for example:

p_manager->getDriver()->drop();

it work

but if i try p_manager->getSceneManager()->drop();

same problem..

the problem is to link getSceneManager??if yes how can i fix it??

tnx a lot
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

i've solved...but i don't understand how...

i've erase inline and now works...mah...
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Inline functions belong in the header file. If you don't care to know why this is a problem, then stop reading now.

When the compiler sees a call to a function that has been previously declared as inline, it generates the code for that function in place of the actual function call. That is what inline means.

Since the compiler knows that you never actually call the function [because it is written inline where the call to the function was], the linker will never even know about the function definition and will not generate an entry in the link table for it.

Travis
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

ok tnx a lot...

so i have to call iniline fuction only in header??when i come back to home i'll try...

instead yesterday i've got another problem:

without inline i can build the project but when i run the exe vc break the execution in line

m_plevelnode = p_manager->getSceneManager()->addOctTreeSceneNode(m_plevelmesh->getMesh(0));

when i go home i'll write here the exact error string...

tnx a lot...
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

ok...

the exact problem is

2 warning:

c:\documents and settings\fabio\desktop\jtpsoft\fps_game\fps-game\fps-game\fps-game\game.cpp(25) : warning C4700: uninitialized local variable 'man' used
c:\documents and settings\fabio\desktop\jtpsoft\fps_game\fps-game\fps-game\fps-game\game.cpp(32) : warning C4700: uninitialized local variable 'level' used

and when i run it:

First-chance exception at 0x00401095 in Fps-Game.exe: 0xC0000005: Access violation reading location 0x217cc0b5.
Unhandled exception at 0x00401095 in Fps-Game.exe: 0xC0000005: Access violation reading location 0x217cc0b5.
The program '[1676] Fps-Game.exe: Native' has exited with code 0 (0x0).


in line

ICameraSceneNode* camera =man->getSceneManager()->addCameraSceneNodeFPS(0,100.0f,300.0f);
camera->setPosition(core::vector3df(-100,50,-150));

of

Code: Select all

#include "game.h"	



//! Costruttore
game::game()
{
}

//! Distruttore
game::~game()
{
}

void game::run()
{
	fps_manager* man;
	fps_gamelevel* level;
	//man->getDevice()->getFileSystem()->addZipFileArchive("media/map-20kdm2.pk3");

	
	
	//level->loadlevel(man,"media/20kdm2.bsp",vector3df(-1370,-130,-1400));
	
	ICameraSceneNode* camera =man->getSceneManager()->addCameraSceneNodeFPS(0,100.0f,300.0f);
	camera->setPosition(core::vector3df(-100,50,-150));

	scene::ISceneNodeAnimator* anim =
		man->getSceneManager()->createCollisionResponseAnimator(
		level->getLevelSelector(), camera, core::vector3df(30,50,30),
		core::vector3df(0,-3,0),
		core::vector3df(0,50,0));

	camera->addAnimator(anim);
	anim->drop();

	man->getSceneManager()->addLightSceneNode(0, core::vector3df(-60,100,400),
		video::SColorf(1.0f,1.0f,1.0f,1.0f),
		600.0f);
	
	while(man->getDevice()-> run()){
		man->getDriver()-> beginScene(true, true, SColor(0,200,200,200));
		man->getSceneManager()-> drawAll();
		man->getDriver()-> endScene();
    }   
   
	man->getDevice()-> drop();
}
this file is for trying the other file and the pointer...
Baal Cadar
Posts: 377
Joined: Fri Oct 28, 2005 10:28 am
Contact:

Post by Baal Cadar »

The error is exactly what the warning hints at. You use man and level without every initialising them. These pointers are not referencing any fps_manager or fps_gamelevel instances and thus you access some random memory here, which in your case results in this access violation exception.

This is, btw, really basic C++ stuff. You should get a good C++ text book and read up on this, before further using code without understanding it. Make sure you understand what you're doing, if not, read about it until you grok it.
No offense :)
jimmythepage
Posts: 16
Joined: Sun May 21, 2006 8:52 pm

Post by jimmythepage »

i will i will..infact my big problem is c++(not irrlicth inself),because i come from java....

tnx for the help..
Post Reply