First off, I have to mention this is probably one of the most beginner-esque questions, not to say pathetically n00b. It probably is because of my lack of C++ experience more than my lack of Irrlicht knowledge, though I hope a great soul could help me solve my problem.
Alright, enough babble, let's get started: I want to make the Irrlicht "Device" and all its "sub-elements" (i.e. driver, smgr, etc.) global. My (not-so-) brilliant idea was to stuff all that into a global header file (originally named "Global.h"). It would consequently also include the basic outline of an Irrlicht structure. Here is my header:
Code: Select all
#pragma once
#include <irrlicht.h>
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")
#endif
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
IrrlichtDevice* Device = createDevice(EDT_DIRECT3D9, dimension2d<s32>(800, 600), 32, false, false, false, 0);
IVideoDriver* Driver = Device->getVideoDriver();
ISceneManager* Scene = Device->getSceneManager();
IGUIEnvironment* Interface = Device->getGUIEnvironment();
ICursorControl* Cursor = Device->getCursorControl();
IFileSystem* Filesys = Device->getFileSystem();
Code: Select all
1>------ Build started: Project: Client, Configuration: Debug Win32 ------
1>Linking...
1>Terrain.obj : error LNK2005: "class irr::gui::ICursorControl * Cursor" (?Cursor@@3PAVICursorControl@gui@irr@@A) already defined in Client.obj
1>Terrain.obj : error LNK2005: "class irr::gui::IGUIEnvironment * Interface" (?Interface@@3PAVIGUIEnvironment@gui@irr@@A) already defined in Client.obj
1>Terrain.obj : error LNK2005: "class irr::video::IVideoDriver * Driver" (?Driver@@3PAVIVideoDriver@video@irr@@A) already defined in Client.obj
1>Terrain.obj : error LNK2005: "class irr::IrrlichtDevice * Device" (?Device@@3PAVIrrlichtDevice@irr@@A) already defined in Client.obj
1>Terrain.obj : error LNK2005: "class irr::scene::ISceneManager * Scene" (?Scene@@3PAVISceneManager@scene@irr@@A) already defined in Client.obj
1>Terrain.obj : error LNK2005: "class irr::io::IFileSystem * Filesys" (?Filesys@@3PAVIFileSystem@io@irr@@A) already defined in Client.obj
1>C:\Night\Code\Debug\Client.exe : fatal error LNK1169: one or more multiply defined symbols found
Oh, and by the way, at the moment, Global.h is called from Terrain.h and Main.cpp.
Thanks, and please forgive my English :')
-Lazlo