Exporting object in DLLs

Started by
5 comments, last by JD 19 years, 7 months ago
hi Forum, I know how to create DLLs but I was wondering how I would go about exporting objects and variables in a dll to the main applications. I know that when u have a function in a dll to be used in the main app, you write something like this before the function signature: __declspec(dllexport) void DoSomething() { //do something... } is this the same with the objects and variables u wanna export? If so, would I write this in the header file or cpp file or both? Thanks in advance DarkStar UK
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Advertisement
class __declspec(dllexport\import) TypeName
{
...
};

All static members should be declared export in the cpp files used to compile the DLL.

That is microsoft specific. I don't know about other windows compilers.
- Jason Citron- Programmer, Stormfront Studios- www.stormfront.com

Also make sure you put the __declaspec(dllexport) on the inner classes/structs. And the variables need a "extern __declaspec(dllexport)" in their declaration ... usually.

Quote:Original post by Clash
All static members should be declared export in the cpp files used to compile the DLL.


I've never had to do declare static members with export...
[size=2]aliak.net
If you want the values of the static members available to the debugger, I've found that exporting them makes that happen. Not to mention, the Microsoft C++ compilers gives warnings when they are not exported.
- Jason Citron- Programmer, Stormfront Studios- www.stormfront.com
Thanks alot guys I will try all of that out

DarkStar
UK
---------------------------------------------You Only Live Once - Don't be afriad to take chances.
Hello,

These articles can be very useful:
Adding Plug-ins To Your Application
Tutorial - Creating And Using DLLs
Using Interfaces with Dlls
Alfred Reinold Baudisch[Game Development Student] [MAC lover] [Ruby, Ruby on Rails and PHP developer] [Twitter]
Maquiavel, the 'using interfaces with dlls' was the best one :)

This topic is closed to new replies.

Advertisement