Problems with Irrlicht Demo

So Microsoft Visual C++ is a good IDE. But, I put in the code exactly right. I know I did, but I keep getting this error:

Main.obj : error LNK2019: unresolved external symbol __imp__createDevice referenced in function _main
c:\users\jim\documents\visual studio 2010\Projects\Sample1\Debug\Sample1.exe : fatal error LNK1120: 1 unresolved externals

These errors occur before it:

c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(11): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(33): warning C4129: 'P' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(33): warning C4129: 'i' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(33): warning C4129: 'm' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(33): warning C4129: 's' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(44): warning C4129: 'P' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(44): warning C4129: 'i' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(44): warning C4129: 'm' : unrecognized character escape sequence
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(44): warning C4129: 's' : unrecognized character escape sequence
Main.obj : error LNK2019: unresolved external symbol __imp__createDevice referenced in function _main

I have a feeling something is wrong in the file path, headers, or linker/libraries/include directories.

Here is the code:

[code][//Irrlicht Demo
#include <irrlicht.h>
//Namespaces
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace io;
using namespace gui;
//Closes Console
#ifdef _IRR WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment((linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
//Begin Program
int main()
{
IrrlichtDevice *device =
createDevice( video::EDT_SOFTWARE, dimension2d<u32>(800, 600), 32,
false, false, false, 0);
if(!device)
return 1;
//Window Caption
device->setWindowCaption(L"Irrlicht Engine Demo");
//Get Drivers
IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
//Static Text
guienv->addStaticText(L"This is the Irrlicht Software renderer!",
rect<s32>(10,10,260,22), true);
//Bring Sydney into window
IAnimatedMesh* mesh = smgr->getMesh("C:\Program Files\irrlicht-1.7.2\media\sydney.md2");
if (!mesh)
{
device->drop();
return 1;
}
//Animation Mesh
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
{
node->setMaterialFlag(EMF_LIGHTING, false);
node->setMD2Animation(scene::EMAT_STAND);
node->setMaterialTexture( 0, driver->getTexture("C:\Program Files\irrlicht-1.7.2\media\sydney.bmp") );
}
//Camera
smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
while (device->run())
{
//Drawing Scene
driver->beginScene(true, true, SColor(255,100,101,140));

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

driver->endScene();

device->drop();
}

return 0;
//End of Execution
}

/code]
Add _IRR WINDOWS_ to prepocesor directives or add this line at the very beginninig of the file:
#define _IRR WINDOWS_ and see if it fixes the linker error.

Also please fix this line:
node->setMaterialTexture( 0, driver->getTexture("C:\Program Files\irrlicht-1.7.2\media\sydney.bmp") );
You MUST use double backslashes in literal strings to insert a backslash, like this:
node->setMaterialTexture( 0, driver->getTexture("C:\\Program Files\\irrlicht-1.7.2\\media\\sydney.bmp") );

This line also:
IAnimatedMesh* mesh = smgr->getMesh("C:\Program Files\irrlicht-1.7.2\media\sydney.md2");
Replace with:
IAnimatedMesh* mesh = smgr->getMesh("C:\\Program Files\\irrlicht-1.7.2\\media\\sydney.md2");
This will fix all your warnings.
Last edited on
okay thank you man, but I got a new list of errors, not so many, but hard to decode for a beginner like me:

c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(14): warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(16): warning C4081: expected 'identifier'; found '('
c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(67): fatal error C1075: end of file found before the left brace '{' at 'c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(20)' was matched
I figured it all out, had the program running then BAM!

Unhandled exception at 0x01c00051 in Sample1.exe: 0xC000001D: Illegal Instruction.
Please copy-paste full content from here to your file, there is no syntax errors like you said:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <irrlicht.h>
//Namespaces
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace io;
using namespace gui;
//Closes Console
//#ifdef _IRR WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
//#pragma comment((linker, "/subsystem:windows /ENTRY:mainCRTStartup")
//#endif
//Begin Program
int main(int argc, char[] argv)
	{
	IrrlichtDevice *device =
		createDevice( video::EDT_SOFTWARE, dimension2d<u32>(800, 600), 32,
		false, false, false, 0);
	if(!device)
		return 1;
	//Window Caption
	device->setWindowCaption(L"Irrlicht Engine Demo");
	//Get Drivers
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();
	IGUIEnvironment* guienv = device->getGUIEnvironment();
	//Static Text
	guienv->addStaticText(L"This is the Irrlicht Software renderer!",
		rect<s32>(10,10,260,22), true);
	//Bring Sydney into window
	IAnimatedMesh* mesh = smgr->getMesh("C:\\Program Files\\irrlicht-1.7.2\\media\\sydney.md2");
	if (!mesh)
		{
		device->drop();
		return 1;
		}
	//Animation Mesh
	IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
		{
		node->setMaterialFlag(EMF_LIGHTING, false);
		node->setMD2Animation(scene::EMAT_STAND);
		node->setMaterialTexture( 0, driver->getTexture("C:\\Program Files\\irrlicht-1.7.2\\media\\sydney.bmp") );
		}
		//Camera
		smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));
		while (device->run())
			{
			//Drawing Scene
			driver->beginScene(true, true, SColor(255,100,101,140));

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

			driver->endScene();

			device->drop();
			}

		return 0;
		//End of Execution
	}
Last edited on
Thank you, syntax is correct, you did make a few mistakes but i quickly solved them. Still got the "illegal instruction error". Please help me solve that thank you.

EDIT: When I read the compile log I saw this, this may be causing my problem:

c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(10) : warning C4067: unexpected tokens following preprocessor directive - expected a newline

Any ideas on how to solve that? I know it must be in the header or at the top somewhere...

This may be a problem to, cant figure out:

c:\users\jim\documents\visual studio 2010\projects\sample1\sample1\main.cpp(11): warning C4067: unexpected tokens following preprocessor directive - expected a newline
Main.obj : error LNK2019: unresolved external symbol __imp__createDevice referenced in function _main
c:\users\jim\documents\visual studio 2010\Projects\Sample1\Debug\Sample1.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
bumped. If this is against rules sorry, need some more help!
BUMPED. PLEASE HELP THANK YOU.
device->drop should be called AFTER the bracket ' } '
so it will come as this:
1
2
3
4
5
6
7
8
9
10
11
while (device->run())
			{
			//Drawing Scene
			driver->beginScene(true, true, SColor(255,100,101,140));

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

			driver->endScene();
			}
               device->drop();

No need to thank.
Topic archived. No new replies allowed.