Jump to content
  • Advertisement
Sign in to follow this  
lord_balron

Creating Engine DLL

This topic is 3623 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

So I'm looking to break my engine apart to separate it from my game code as it is now. The problem is, I'm not quite sure what and how to move my engine code into the DLL and accompanying .LIB. Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Which IDE/programming environment are you using? MSVC should make it fairly simple to set up a DLL based project. Also if you put an EXE project in the same solution and set the DLL as a 'dependency', then it will automatically link to your LIB file for you.

Most DLL libraries usually define the IMPORT and EXPORT keywords. These keywords, when used in your header files either tell the compiler that this class is being exported by the currently compiling code (e.g. when compiling a DLL), or that it has to be imported (from a DLL) by the currently compiling code (e.g. when compiling a EXE).
#ifdef WIN32 
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#else
#define EXPORT
#define IMPORT
#endif
And then they define a keyword that identifies classes (etc) as being part of your DLL:
#ifdef COMPILING_MY_DLL
#define MY_DLL EXPORT
#else
#define MY_DLL IMPORT
#endif

//Use it like this:
MY_DLL class MyClass
{
...
In the project properties of your DLL, add COMPILING_MY_DLL to the preprocessor definitions. Now the compiler will know that classes marked with MY_DLL have to be exported when compiling the DLL, and have to be imported when compiling an EXE.

Share this post


Link to post
Share on other sites
Using your example would MY_DLL flag everything as part of the dll if the flag is put in front of the class, or will I need to put that before every function too?

Share this post


Link to post
Share on other sites
Sorry to bump, but I've got it generating a DLL file.

The only thing is I don't know how to get Visual Studio 2005 to generate the Import Library as well.

Again, any help is greatly appreciated.

Share this post


Link to post
Share on other sites
Be sure you compile the lib as dynamic library and the applicatiion as exe.
Be sure you put COMPILING_MY_DLL in the preprocessor definitions of the library.
Be sure you add the lib file to the additional dependencies (of linker) of the application (something like "$(OutDir)\Engine.lib").
Be sure the app and the lib have the same output folder.

Here you can download a sample I have built for you.

Hope it helps! ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!