Archived

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

Setting up this DLL o' mine

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

Lets see, I have a dll that i made. it compiles fine. I have all the functions int the DLL files declared as follows: void __declspec(dllexport) blahblahblah()... int __declspec(dllexport) more_blah(void** pointer).... etc. So, for me to use this DLL, ill have to create a header file (not included in the DLL), that looks like this: void __declspec(dllimport) blahblahblah()... int __declspec(dllimport) more_blah(void** pointer).... is this correct, the way i have it set up? Also, how would I create a data abstraction (such as a class) and be able to export it without having to actually define an instance of it to export (from within a DLL/Import Library)?

Share this post


Link to post
Share on other sites
Yep, that''s the way to do it for functions.

For classes, just put the _declspec(dllexport) macro inbetween class and class name in your headers, i.e:

class _declspec(dllexport) myClass
{
...etc
}

However, this would then require two sets of headers - one for internal use, and one for use in import. So, do something like this:

#ifdef MYDLL_EXPORT
#define MYDLL_API _declspec(dllexport)
#else
#define MYDLL_API _declspec(dllimport)
#endif

And then declare your classes thus:

class MYDLL_API myClass
{
}

And only #define MYDLL_EXPORT when you are building your dll.

Hope this helps,

Henry

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Actually, I just have

#define DllExport __declspec(dllexport)
#define DllImport __declspec(dllimport)

But thx anyway. I can''t use __declspec(dllexport) on a constant initialized value tho, which kinda sucks, like:

const int __declspec(dllexport) ON = 1;

Share this post


Link to post
Share on other sites