Where can i get a brief info on creating .Dll's

Discussion about everything. New games, 3d math, development tips...
Post Reply
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Where can i get a brief info on creating .Dll's

Post by Lil Margin »

Hi,
I have searched Google on the .dll subject and i got a few tutorials which helped allot but i feel that its not enough information to get me going.

Do you know where i can find great articles or even books(even if the .dll topic is only present in only 1 chapter) on the .dll creation topic?



Thanks in advanced.
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Post by cobra »

It's very easy. To get you started, just open up Code::Blocks or MSVC and create a new project of type "Win32 DLL" or something along those lines.

It should give you some code to get started, and the rest is self-explanatory.


Good luck!
Josiah Hartzell
Image
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Post by Lil Margin »

I tried that but i start to get errors and i dont know why(mainly becaise i lack info)

i am getting a list of errors :
error C2143: syntax error : missing ';' before '*'
: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
: error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\Engine.cpp(5) : warning C4273: 'Engine::InitEngine' : inconsistent dll linkage
1> c:\work\engines\tradur\tradur\Engine.h(24) : see previous definition of 'InitEngine'
1>.\Engine.cpp(9) : error C2065: 'guienv' : undeclared identifier
1>.\Engine.cpp(13) : warning C4273: 'Engine::CloseEngine' : inconsistent dll linkage
1> c:\work\engines\tradur\tradur\Engine.h(25) : see previous definition of 'CloseEngine'
1>.\Engine.cpp(18) : warning C4273: 'Engine::returnDevice' : inconsistent dll linkage
1> c:\work\engines\tradur\tradur\Engine.h(28) : see previous definition of 'returnDevice'
1>.\Engine.cpp(23) : warning C4273: 'Engine::UpdateEngine' : inconsistent dll linkage
1> c:\work\engines\tradur\tradur\Engine.h(27) : see previous definition of 'UpdateEngine'
1>.\Engine.cpp(26) : error C2065: 'guienv' : undeclared identifier
1>.\Engine.cpp(26) : error C2227: left of '->drawAll' must point to class/struct/union/generic type
1> type is ''unknown-type''
1>.\Engine.cpp(31) : warning C4273: 'Engine::WindowSetCaption' : inconsistent dll linkage
as i have seen in other example you dont export everything in a class but only the class itself so i did thesame thing :

Engine.h :

Code: Select all

#ifndef _DLL_ENGINE_H_
#define _DLL_ENGINE_H_

#if defined DLL_EXPORT
#define DECLDIR __declspec(dllexport)
#else
#define DECLDIR __declspec(dllimport)
#endif

#include <irrlicht.h>
using namespace irr; //namespace for the graphics engine, makes it easier to read

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

extern "C"
{

class DECLDIR Engine
{
public:
void InitEngine(int x, int y, bool fullscreen); //starting the engine up
 void CloseEngine(); //shut the engine down
 void WindowSetCaption(const wchar_t* caption); //change the caption
 void UpdateEngine();
 IrrlichtDevice* returnDevice();
private:
	IrrlichtDevice* mydevice;
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guienv;


};

}

#endif
Engine.cpp

Code: Select all

#include "Engine.h"
#define DLL_EXPORT

void Engine::InitEngine(int x, int y, bool fullscreen)
{
mydevice = createDevice(video::EDT_OPENGL, dimension2d<u32>(x, y), 16, fullscreen, false, false, 0);
driver = mydevice->getVideoDriver();
smgr = mydevice->getSceneManager();
guienv = mydevice->getGUIEnvironment();
}

void Engine::CloseEngine()
{
mydevice->drop();
}

IrrlichtDevice *Engine::returnDevice()
{
return mydevice;
}

void Engine::UpdateEngine()
{
		driver->beginScene(true, true, SColor(255,100,101,140));
		smgr->drawAll();
		guienv->drawAll();
		driver->endScene();
}

void Engine::WindowSetCaption(const wchar_t* caption)
{
	mydevice->setWindowCaption(caption);
}

I dont know why i am getting this error and Googling did not get me very far either...

Do you know why i am getting this error?
[edit]Yes, everything is proper linked...
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

We figured out that he simply forgot to add the gui namespace. :lol:

(and DECLDIR may have been defined incorrectly...)
DeM0nFiRe
Posts: 117
Joined: Thu Oct 16, 2008 11:59 pm

Post by DeM0nFiRe »

Post Reply