static libs vs DLLs

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
ElectroDruid
Posts: 23
Joined: Thu Oct 21, 2004 3:55 pm

static libs vs DLLs

Post by ElectroDruid »

Hi,

I'm not a beginner programmer, but I haven't used Irrlicht much and I'm very rusty with regards to Windows programming (I work on consoles mainly). I've been looking into compiling Irrlicht as a static lib rather than a DLL, largely because I don't know what the advantage of a DLL is, and it's another file that I'd need to package up with any finished game - if I'm basing my engine on Irrlicht, it seems preferable to have all of the Irrlicht code ending up being contained within my game executable.

I see that Irrlicht doesn't seem to be set up to work as a lib too well under Windows, although I did a search and discovered that there is a way to coax it into doing so (http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2709). What I haven't been able to find are the arguments for and against bothering to try. What are the advantages and disadvantages of choosing a DLL over a lib, or vice versa?

Opinions gratefully received :) Cheers
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Using a static lib would make the SDK quite large. It contains 15 examples which would hold 15 copies of the 2-3MB library. So additional and completely redundant 30 MB. Other than that there are not too many advantages. Using dlls also makes updating simpler, however only if the API has stabilized which is not true for Irrlicht.
ElectroDruid
Posts: 23
Joined: Thu Oct 21, 2004 3:55 pm

Post by ElectroDruid »

I guess I'd strip out the sample code for my project, I don't need it. But then that would create one more job to do (on top of updating code that used interfaces that have changed) if I want to update in the middle of a project, which could be a pain.

I'll probably end up running with DLLs for the sake of a quiet life.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

If you use a static lib you don't need to handle all the different Irrlicht versions out there, because every exe has it's own dll inside itself !!!
Well, you also can copy the dll into every project folder, but I don't like this...
The main reason I'm using static libs is, because they are a little bit faster (because no dynamic linking is neccessary as it is with dlls)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
ElectroDruid
Posts: 23
Joined: Thu Oct 21, 2004 3:55 pm

Post by ElectroDruid »

@ Acki: Did you use a method like the one in the thread I linked to in my first post to get it working as a lib? Or did you do something else.

I got my project setup to use DLLs, and thought I was done - until I realised I couldn't step into the Irrlicht function calls with a debugger :( Which has pretty much made me decide that I definitely want a static lib, if only for ease of debugging. Just wanted to check that the method I found for doing the static lib stuff was the best one available.
Cppuser
Posts: 12
Joined: Thu Sep 28, 2006 8:38 pm

Post by Cppuser »

Acki wrote: The main reason I'm using static libs is, because they are a little bit faster
On which situation?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Well, the two files are correct and changing the project to static lib, but do the following:
search for

Code: Select all

#ifdef IRRLICHT_EXPORTS
#define IRRLICHT_API __declspec(dllexport)
#else
#define IRRLICHT_API __declspec(dllimport)
#endif // IRRLICHT_EXPORT
#else
#define IRRLICHT_API 
and change it to:

Code: Select all

#ifdef IRRLICHT_EXPORTS
#define IRRLICHT_API// __declspec(dllexport)
#else
#define IRRLICHT_API// __declspec(dllimport)
#endif // IRRLICHT_EXPORT
#else
#define IRRLICHT_API 
Or simply use my IrrExtensions !!! ;)

@cppuser:
in general...
it's the same like using an static var for example to get the guiEnvironment...
sure you can every time call getGUIEnvironment, but this causes everytime 1 or 2 program steps, instead of getting it one time into a static var...
SUre with todays cpu powers it doesn't really matter, but it's fact...
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply