Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

DLLs


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 25 November 1999 - 02:26 PM

I just finished the GUI for my new game, and it works perfectly, but I wanted to make it into a DLL. I've looked around quite a bit, but I havn't seen any tutorial on "How to make DLLs". I'm using Borland C++ 5, so if anyone knows any tutorials, or finds it simple enough to tell me right here, thanks! (Oh, and if you ONLY know how to do it for MSVC++, that's okay too, I could probably translate it okay! Thanx again!)

Sponsor:

#2 Shinkage   Members   -  Reputation: 586

Like
Likes
Like

Posted 24 November 1999 - 06:16 AM

The only real difference with MSVC is that Microsoft has created their own little standard for declaring DLL imports and exports. Here's a little example of how to make a DLL you can import into other projects.

//
// MyDLL.h
//

// Visual C++ version
#ifdef MYDLL_IMPORT
#define MYDLL_API _declspec(dllimport)
#else
#define MYDLL_API _declspec(dllexport)
#endif

// You'll have to find the way Borland declares variables as imported/exported
// and replace _declspec(...) with the appropriate commands

// Force compiler to use undecorated function/variable names.
// This is most useful if you plan to dynamically link the DLLs.
extern "C"
{
void MYDLL_API MyDLLFunc( void );
}

//
// MyDLL.cpp
//

#include "MyDLL.h"

void MYDLL_API MyDLLFunc( void )
{
}

Add the two above files to an empty DLL project and it will compile a DLL that exports one function (MyDLLFunc) that does nothing. You get the idea. Also, to import the DLL into a project, link the project to the .lib file compiled with the DLL and include the .h file like this:

//
// MyProject.cpp
//

#define MYDLL_IMPORT
#include "MyDLL.h"

Then you can just call the functions exported in the DLL wherever you like. If you want to dynamically load the DLLs (load them without having to link to their lib), check out the Windows API commands LoadLibrary and GetProcAddress.


#3 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 24 November 1999 - 06:43 AM

Microsoft simply included that for simplicity and inline exporting and importing. If you want to do it the "old fashioned" way, you can construct a .DEF file that contains the information necessary to the compiler for creating the DLL. MSDN (as always) has a bunch of info on this method. MSDN is my friend...

- Splat


#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 25 November 1999 - 09:05 AM

Alright, first, thanks for your replies, it answered my original question but I think I left something out, how would I export classes (and, for that matter, import them) ?

Thanks again for any replies!


#5 Niels   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 November 1999 - 11:34 AM

Splat: I hope at least some of your friends are less annoying ...

/Niels


#6 Splat   Members   -  Reputation: 122

Like
Likes
Like

Posted 25 November 1999 - 02:26 PM

Hey, you insulting MSDN Library? I thought not...

Actually, I've initially learned a whole shit load of stuff from MSDN, it is the reason Win32 development is much better than any other platform. I mean, yes, every so often MSDN is wrong (gotta love the "undocumented" features of the Platform SDK), but what other platform can you in 5 seconds have a detailed syntaxical listing of a function with the desciption of each return value, quirks, and what it actually does?

However, some of my friends are A LOT more annoying than MSDN.

- Splat





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS