I've got so many problems with my code, so please help me!

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
Guest

I've got so many problems with my code, so please help me!

Post by Guest »

Here is my firs problem:
How to Compile a Linux Game? Where can I find a tutorial for that?
And my second:
Here is my Code, but I'm still searching for the error. The Compiler says:"
1 unaufgeloester externer Verweis in" something "_16@" or something. Here is my code...It should be an Linux Game.

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 g_puneshed;
int g_score;
int g_end;
ISceneNode* g_scnode = 0;
int ahamster[9];
int arabit[9];

class KEYS_INPUT : public IEventReceiver
{
	public:
		virtual bool OnEvent(SEvent event)
		{ 
			if (g_scnode != 0 && event.EventType == EET_KEY_INPUT_EVENT&& !event.KeyInput.PressedDown)
			{
			g_end = 0;
			switch(event.KeyInput.Key )
			{
				case KEY_NUMPAD1 :
				{
					g_puneshed = 1; 
				}
				case KEY_NUMPAD2 :
				{
					g_puneshed = 2; 
				}
				case KEY_NUMPAD3 :
				{
					g_puneshed = 3; 
				}
				case KEY_NUMPAD4 :
				{
					g_puneshed = 4; 
				}
				case KEY_NUMPAD5 :
				{
					g_puneshed = 5; 
				}
				case KEY_NUMPAD6 :
				{
					g_puneshed = 6; 
				}
				case KEY_NUMPAD7 :
				{
					g_puneshed = 7; 
				}
				case KEY_NUMPAD8 :
				{
					g_puneshed = 8; 
				}
				case KEY_NUMPAD9 :
				{
					g_puneshed = 9; 
				}
				case KEY_ESCAPE  :
				{
					g_end = 1;
				}
				return true;
			}
			}
		}
};

void test_puneshed()
{
	if(ahamster[g_puneshed] == 1)
	{
		g_score = g_score + 10;
	}
	if(arabit[g_puneshed] == 1)
	{
		g_score = g_score - 10;
	}
}


void main()
{
	KEYS_INPUT KEYS;
		IrrlichtDevice *device = createDevice(EDT_SOFTWARE, dimension2d<s32>(512, 384), 16, false, false, &KEYS);
	//Text in der Titelleiste des Fensters erzeugen... dabei steht das L für die "wide character strings"
		device->setWindowCaption(L"Wacko");
	//Pointer auf den Video Treiber, den ScenenManager und der GUI setzten.
		IVideoDriver* driver = device->getVideoDriver();
		ISceneManager* smgr = device->getSceneManager();
		IGUIEnvironment* guienv = device->getGUIEnvironment();
	//Text anzeigen
		guienv->addStaticText(L"This is Wacko for Linux",
		rect<int>(10,10,200,30), true);
		IAnimatedMesh* hamster = smgr->getMesh("models/hamster.ms3d");
		IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( hamster );
		
		IAnimatedMesh* rabit = smgr->getMesh("models/rabit.ms3d");
		node = smgr->addAnimatedMeshSceneNode( rabit );


		if(node)
		{
				node->setMaterialTexture(0, driver->getTexture("textures/firsttree.bmp"));
		}
		while(device->run())
		{
					if(g_end == 1)
					{
						break;
					}
				smgr->addCameraSceneNode(0, vector3df(0, 10, -40), vector3df(0,0,0));
				test_puneshed();
				driver->beginScene(true, true, SColor(0,100,100,100));
				smgr->drawAll();
				guienv->drawAll();
				driver->endScene();
		}
	device->drop();
}
...AND HERE IS MY Third Problem:
How I become a random Number between 1 and 9?

That's all,
thanks a lot!
PS: Sorry for bad english!

Fliege
andy0482
Posts: 23
Joined: Mon Sep 13, 2004 6:22 pm

Random numbers

Post by andy0482 »

For random numbers on linum search for man pages or on google for

srand48
drand48

Also you can use getpid to seed srand48 before getting numbers.

About your other problem make sure your make file links to the directory that has the compilled liberary for linux.

Hope it helps

BTW dont worry about your english. I was born to speak english and I still have problems with it! ;)
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

bad english is the american way 8) :P
Guest

Post by Guest »

But I have a windows system, I when I would be finished, I would ask a Linux - User to test my game... :mrgreen:
It's terrible! I tried everything, even with DEVCpp and it won't work. :cry:
Is someone able to send me a list of all the libaries i have to include?
Irrlicht programming is fun!
I Like it because I tried pure DirectX9 and it was to hard for me... :lol:
Ok, I have to go out with my dog,
Godnight
Fliege
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

Winner of Robomaniac's Award for Vaugest error message :)

What is the rest of the error, with it we can normally point you to a lib you didn't link ro something. Just post the whole error, and we can guide you in the right direction
The Robomaniac
Project Head / Lead Programmer
Centaur Force
LordNaikon
Posts: 164
Joined: Wed May 05, 2004 5:34 pm
Location: Germany Berlin
Contact:

Post by LordNaikon »

yea please paste the whole error here. i have got you , you are german :D
not only because of that "1 unaufgeloester externer Verweis in" something "_16@" " you could work also with a German compiler however english to speak. but i have "unmasked" you by this sentence "How I become a random Number between 1 and 9? " i think it is the most frequent mistake germans do. I had to fight years with that
q|^.^|p beeing every time friendly to everyone
sys: 2500+Barton 512MB 6600GT WinXP
Robomaniac
Posts: 602
Joined: Sat Aug 23, 2003 2:03 am
Location: Pottstown, PA
Contact:

Post by Robomaniac »

its the ever present:

Unresolved External Symbol error :)
The Robomaniac
Project Head / Lead Programmer
Centaur Force
Guest

Post by Guest »

Oh yes, I said that I'm not good at english...Please don't tell that my Englishprofessor! :lol: :lol:
But, now I can tell you the hole error:
Kompilierung läuft...
main.cpp
c:\eigene dateien\lukas programmierungen\c++\linux games\wacko\main.cpp(72) : warning C4715: 'KEYS_INPUT::OnEvent' : Nicht alle Steuerelementpfade geben einen Wert zurück
Linker-Vorgang läuft...
LINK : warning LNK4075: /EDITANDCONTINUE wird aufgrund der Angabe von /INCREMENTAL:NO ignoriert
LIBCD.lib(wincrt0.obj) : error LNK2001: Nichtaufgeloestes externes Symbol _WinMain@16
Debug/Wacko.exe : fatal error LNK1120: 1 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.
Oh yea, my sentence was very cool 8) 8)
"How I become a random number between 1 and 9" means
"Wie werde ich eine zufällige Zahl zwischen 1 und 9"
It's cool, I really thought that I had written a text without any mistakes and I was so proud and now......
I hope you can help me now.
All the best
Fliege

PS: The simplest way to "unmask" me would be to look at my Nickname, but your'e right, I'm German!
Guest

Post by Guest »

It looks like your compiler is trying to link a windows executable.
WinMain is called by Windows' GUI environment - instead of main, which is used by just about every other programming environment.

My guess is that the linker tries to create a jump table with the main function as well as the WinMain function in it, but since there is none (and there is no point, since it's not going to run in Windows anyway here), the linker can't find it. That's why you get the error message.
Guest

Post by Guest »

Ohh yes...That's the problem.... :lol:
I always take a windows application for a new project...Should I tak a Consoleprogramm?
turboferret
Posts: 49
Joined: Thu Aug 12, 2004 12:42 pm
Location: Sweden
Contact:

Post by turboferret »

you can't compile for linux under windows.
This monkey is useless, it only has ONE ass!!!
Guest

Post by Guest »

I know, in the End I'll install Linux on another Computer to compile it. But there is another problem:
If I press any Key, it happens nothing :shock: :?
What should I do?
Post Reply