[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

Multiple c++ classes to a DLL ?

Hello all,
   i have come across a module in my project to export multiple c++ classes to a single win32 DLL(not MFC).can anyone help me how to export multiple classes where each class are in separate files?.
regards,
ashok
0
ashkumarc
Asked:
ashkumarc
1 Solution
 
makerpCommented:
i think thast you can just put

__declspec(dllexport)
class X
{

};

you will need to use pre-processor defs to change this to

__declspec(dllimport)
class X
{

};

when importing

#ifdef _DLL
__declspec(dllexport)
#else
__declspec(dllimport)
#endif
class X
{

};
0
 
AlexFMCommented:
Create Win32 Dll using VC++ Application Wizard, select "A Dll that exports some symbols". Read the code genetated by Wizard. It contains one exported class.
You can add any number of such classes to your Dll placing their code to separate .h and .cpp files.
Every .h file which contains exported class definition should contain the lines:

#ifdef SAMPLE_EXPORTS
#define SAMPLE_API __declspec(dllexport)
#else
#define SAMPLE_API __declspec(dllimport)
#endif

and class should be defined as:

class SAMPLE_API <class name>
{
};

(SAMPLE is project name).
0
 
udilCommented:
This question has been abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.

In the absence of responses, I may recommend DELETE unless it is clear to me that it has value as a PAQ. Silence = you don't care

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Udil
EE Cleanup Volunteer
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now