Solved

DLL in C++ classes

Posted on 1997-03-01
2
223 Views
Last Modified: 2010-04-10
How to declare member function in def file of class ?

Declaretion as dll_name.class_name.function_name doesn't
correct.
0
Comment
Question by:a121496
2 Comments
 
LVL 3

Expert Comment

by:os012897
ID: 1162125
Can you be a bit more specific on what compiler you are using??

Regards,

         os

0
 

Accepted Solution

by:
pangofil earned 50 total points
ID: 1162126
It depends on the compiler You are using :
each one has his own naming convention.

But You can declare whole class as __export
and leave DEF file default.

#ifdef __DLL__
#define MYCLASSDEC __export
#else
#define MYCLASSDEC __import
#endif

class MYCALSSDEC MyClass
 {
   .....

 } ;

After linking DLL, make LIB file for it ( by IMPLIB utility ) and link LIB file to EXE You are callin DLL from.

It works for BC++ & VC++

Another way to do it :

Make outclass function, what calls class memeber function :

extern "C"
{
 int FAR PASCAL __export MyCallFunc ( ... )
  {
    return my_class.MemeberFunc ( ... ) ;
  }
}

MyCallFunc can be defined as EXPORT in DEF file.

Hope, it helps.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now