Archived

This topic is now archived and is closed to further replies.

DLL creation

This topic is 4949 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have a bunch of "plugin like" include files (.h) but i want to make them into actual dll''s not just header files ... basically i have my main engine source which makes calls to the specific include file ... that i call "plugin files" all the plugin files have the same namespace PluginMain, and the same global functions withen them, this lets me write the function calls in my main source and never have to touch it except when i want to change the "plugin file it uses" ... so for instance i have a pong game all i do is include "pongPlugin.h" at the start of my engine and everything is set up so it will work ... i have a break out plugin as well, so as you might have guessed it''s set up to work in the same fashion as well. the reasons for doing this is obvious, why have multiple programs with 400 lines of the exact same opengl and windows init code withen them ... this system works fine, just include the header files and compiling the main program after modifying the headed file im working on ... but i think it would be a much better idea to compile the mian executable once and compile the plugin files into actual dll''s when i modify them ... then on startup of the main engine i can just select which dll i want ... this seems like the obvious thing to do, however i have no f***ing clue how to do this ... is it that much harder to convert what i have into using dll''s??? any help or links to tutorials is greatly appreciated!

Share this post


Link to post
Share on other sites
Alternatives:

1. Build the engine as a DLL, and make the games as exes, and call its routines
2. Build the engine as a static lib
3. Build one (not so) big exe with all the games in, which determines which one to run by command line parameter or something

Basically, I''d say, if you have no reason to have a .DLL, don''t make one.

Mark

Share this post


Link to post
Share on other sites
Well, DLL''s work by a simple means.

A DLL has a bunch of code in it. Not much else.
It has a list of function names which Windows knows how to read.

In your program, you call LoadLibrary("myEngine.dll") to load the DLL into memory.

Then, you have to know how to use function pointers. Best go learn those now. Use Google.

/* Typedef for a function pointer */
typedef int (*HGAMEINIT)( void );

HMODULE hDLL = LoadLibrary("myEngine.dll");
HGAMEINIT gameinitfunction = GetProcAddress( hDll, "gameInit" );

gameinitfunction();

I''ve got a great example project in VC++ which demonstrates how to build and use DLLs for practical purposes, but I don''t have any webspace to put it in. Email me if you want it. My email is tiogshi@spamhotmail.com (delete the "spam" part, I''m just trying to throw off address scanners)

Share this post


Link to post
Share on other sites