?
Solved

Multiple c++ classes to a DLL ?

Posted on 2003-02-19
3
Medium Priority
?
406 Views
Last Modified: 2010-05-18
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
Comment
Question by:ashkumarc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
makerp earned 300 total points
ID: 7980298
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
 
LVL 48

Expert Comment

by:AlexFM
ID: 7980324
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
 
LVL 2

Expert Comment

by:udil
ID: 8867127
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question