Dodgy 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
Mooncabbage
Posts: 2
Joined: Sat Nov 12, 2005 5:44 am

Dodgy Linker Error

Post by Mooncabbage »

I've ended up, for a number of convoluted reasons, trying to use Irrlicht with Visual C++ 2005 Express Edition, and I get a dodgey linker error. I've spent the last few hours trying to work it out, reading through help and all other gadgets, and I must admit to being completely stumped.

Code: Select all

#include <irrlicht.h>

using namespace irr;

using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

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

int main()
{
	IrrlichtDevice *device = createDevice(EDT_SOFTWARE, dimension2d<s32>(640, 480), 16, false, false, false, 0);

	device->setWindowCaption(L"Hello World! - Irrlich Engine Demo");
	
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();

	guienv->addStaticText(L"Hello World! This is the Irrlicht Software engine!", rect<int>(10,10,200,22), true);

	IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);

	if(node);
	{
		node->setMaterialFlag(EMF_LIGHTING,false);
		node->setFrameLoop(0,310);
		node->setMaterialTexture(0,driver->getTexture("../../media/sydney.md2"));
	}

	smgr->addCameraSceneNode(0,vector3df(0,30,-40),vector3df(0,5,0));

	while(device->run())
	{
		driver->beginScene(true, true, SColor(0,200,200,200));

		smgr->drawAll();
		guienv->drawAll();

		driver->endScene();
	}

	device->drop();

	return 0;
}
The tutorial code, obviously :P. But copied exactly incase someone can see a typo I can't.

That generates this spew:

Code: Select all

Linking...
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 *,wchar_t const *)" (?createDevice@irr@@YAPAVIrrlichtDevice@1@W4E_DRIVER_TYPE@video@1@ABV?$dimension2d@H@core@1@I_N22PAVIEventReceiver@1@PB_W@Z) referenced in function _main
C:\Documents and Settings\Mooncabbage\My Documents\Visual Studio 2005\Projects\Project1\Debug\Hello World.exe : fatal error LNK1120: 1 unresolved externals
Please, if this is just Visual C++ being dodgy, I can deal with that, because apparently the 2003 toolkit is back up, and i'll just set that up with code::blocks, but if it's not, can you PLEASE tell me what the problem is. I've never had any luck with linking stuff, but this has me completely confused.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

You need to add the path to the Irrlicht lib file, either in the Visual Studio Options or in the individual project options.
Image
jam
Posts: 409
Joined: Fri Nov 04, 2005 3:52 am

Post by jam »

I'm having the same problem,

I've added the path by clicking tools->Options...->Projects and Solutions->VC++ directories->show directories for: library files->F:\irrlicht.12\lib\Win32-VisualStudio
Artenius
Posts: 8
Joined: Wed Aug 31, 2005 4:29 pm
Location: a 3d matrix full of things I don´t understand now.

Post by Artenius »

Yeah, I got same prob. But

Code: Select all

#pragma comment(lib, "Irrlicht.lib")
tells the irrlicht lib location anyway. You just receive a warning if you don´t compile it together. vc++ consider string if irrlicht.lib is not called but it still gives the same error anyway.

I tryed reversing old standarts via command line as it is said to do in msdn help but no way I can compile irrlicht app due to this linker error.

Anyone got more ideas?

-------------------------

[UPdate]

I found a solution for our problem. As I said I read in msdn help that a solution could be to reverse to old standart. I made it via command line but for some weird reason it didnt work. However when I did via the options screen it worked.

Just hit ALT+F7. Then, go to C/C++ -> Language.
There you will find: "Treat wchar_t as Built in type". Set it to "NO".

This will set wchar_t to old standarts used by irrlicht and it will compile right. You can do either this or update irrlicht engine with new standarts.

By the way, updating it could be a good feature for next irrlicht milestone.

[END update]

------------------
AndyCR
Posts: 110
Joined: Tue Nov 08, 2005 2:51 pm
Location: Colorado, USA
Contact:

Post by AndyCR »

Artenius wrote:-------------------------

[UPdate]

I found a solution for our problem. As I said I read in msdn help that a solution could be to reverse to old standart. I made it via command line but for some weird reason it didnt work. However when I did via the options screen it worked.

Just hit ALT+F7. Then, go to C/C++ -> Language.
There you will find: "Treat wchar_t as Built in type". Set it to "NO".

This will set wchar_t to old standarts used by irrlicht and it will compile right. You can do either this or update irrlicht engine with new standarts.

By the way, updating it could be a good feature for next irrlicht milestone.

[END update]

------------------
It works perfectly for me without doing that. Did you rebuild irrlicht.dll and irrlicht.lib using MSVC++ 2005? if not, thats the problem.
Artenius
Posts: 8
Joined: Wed Aug 31, 2005 4:29 pm
Location: a 3d matrix full of things I don´t understand now.

Post by Artenius »

AndyCR wrote:
Artenius wrote:-------------------------

[UPdate]

I found a solution for our problem. As I said I read in msdn help that a solution could be to reverse to old standart. I made it via command line but for some weird reason it didnt work. However when I did via the options screen it worked.

Just hit ALT+F7. Then, go to C/C++ -> Language.
There you will find: "Treat wchar_t as Built in type". Set it to "NO".

This will set wchar_t to old standarts used by irrlicht and it will compile right. You can do either this or update irrlicht engine with new standarts.

By the way, updating it could be a good feature for next irrlicht milestone.

[END update]

------------------
It works perfectly for me without doing that. Did you rebuild irrlicht.dll and irrlicht.lib using MSVC++ 2005? if not, thats the problem.
Well, when I tryed the first time to rebuild irrlicht without doing it I received the same errors. So no it had nothing to do. I tryed it anyway. It was the first thing I thought about. However after I made the mod recommended by microsoft it worked pretty good. Anyway, it´s much easier to change one little setting than rebuilding the entire project altho I made it later. One way or the other I had to do it.
Mooncabbage
Posts: 2
Joined: Sat Nov 12, 2005 5:44 am

Post by Mooncabbage »

Thanks for your help everybody. I hadn't thought of rebuilding the libraries, I guess I'll have to do that won't I? Good to know I wasn't the only one with the problem either ^^.
Post Reply