Exporting '& Importing classes and functions when building multiple DLLs
Posted
by Xiangyang (Sean) Liu
on April 18th, 1999
His solution does not work in the situation where dll A uses classes in dll B and dll B also uses classes in dll A. I have found a much simpler solution which solves these problems elegantly.
Suppose we want to build a dll called MyDllA. First we define the following macros:
#ifdef BUILD_MYDLLA #define MYDLLA_EXPORT __declspec(dllexport) #else #ifdef USE_MYDLLA #define MYDLLA_EXPORT __declspec(dllimport) #else #define MYDLLA_EXPORT #endif #endifThen we declare classes, functions, and data in MyDllA using the macro MYDLLA_EXPORT, for example:
class MYDLLA_EXPORT MyClass
{
...
};
When compiling MyDllA, we define the macro BUILD_MYDLLA in the project
setting. When compiling a dll that uses classes in MyDllA, we define the
macro USE_MYDLLA in its project setting. The same trick can be applied when
build MyDllB, MyDllC, etc. Note that the source code doesn't have to be
changed if we decide to make MyDllA a static library instead (in that case,
don't define the macros BUILD_MYDLLA and USE_MYDLLA when compiling the
project).
Date Last Updated: April 18, 1999

Comments
Lightweight perceptive â Nike Unshackled TR Attack in divulge 2013 3 series
Posted by Tufffruntee on 04/19/2013 10:56pmNike Emancipated TR Suited 3 noteworthy features is to exploit the additional design: Nike Free 5 soles improved bending Striation; supplemental tractor layout making training more focused when; lighter preponderance, the permeability is stronger, and more in fashion shoe designs not only exhort shoes [url=http://markwarren.org.uk/goodbuy.cfm]nike free run[/url] more smug wearing, barefoot training feel, but also more in vogue appearance. Nike On the house TR Fit 3 provides supreme lateral solidity, you can take the legs in the part during training. Strong vamp nobles breathable mesh, lower soap up's solitary lay out can be [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache[/url] seen through it. Lightweight, difficult, reduce bubbles means occupied by very some seams, more flexible, help is stronger. Requirement more help, department of a training irritate, bubbles make inaccessible in more parts of the need in return flexibility, effervescence loose. Say double say nothing moisture wicking mock materials, unshiny on your feet, refrain from keep feet sear and comfortable. Phylite [url=http://turbo-vac.co.uk/components_13.cfm]nike free uk[/url] midsole offers lightweight surprise level, special durability and even outsole can do to greatly turn the all-embracing dialect heft of the shoe. Qianzhang pods on the outsole and heel-shaped Na媣e rubber enhances the shoe multi-directional gripping power on sundry surfaces.
ReplyExporting C++ classes using .def files.
Posted by shalmi on 09/21/2007 01:18amHi, .def files are used when we do not want to use __declspec(dllexport). But how can we export whole class using .def files? I tried to do so but then there is linking error in .def file for constructor and destructors. Why so? Is there any solution to this? Thanks in advance.
ReplyVery good!!!
Posted by Legacy on 09/01/2003 12:00amOriginally posted by: CarioLee
Very good!!!Worked well!
ReplyExport class from DLL
Posted by Legacy on 08/25/2002 12:00amOriginally posted by: Jonathan Liu
I try to export a class containing a template member function. I got "error LNK2001: unresolved external symbol ..." linking error when compiling a exe using that dll. Appriciate any idea to solve the problem!
ReplyA good web link for DLL Exporting & Importing
Posted by Legacy on 08/20/2002 12:00amOriginally posted by: Tiny Young
ReplyA Example pleae
Posted by Legacy on 10/06/2001 12:00amOriginally posted by: Henry Casta�eda
ReplyC++, classes, DLLs and destructor
Posted by Legacy on 05/18/2001 12:00amOriginally posted by: Christophe
Hello,
I have some problems with DLL:
I am creating a DLL which have a class definition (C++).
All is working (export, import, and execution) but when the destructor is called, I've got an error message (EAccessViolation...)
Please!! I need some help.
Christophe (France).
Replyexporting a class from a DLL
Posted by Legacy on 03/12/2001 12:00amOriginally posted by: Jason
ReplyExporting DLL's and headers
Posted by Legacy on 05/26/2000 12:00amOriginally posted by: IMAD MURAD
I am working on an image processing software written in visual C++ 6.0
One problem I am having is with the _export statement. Replaciong it with _declspec(dllexport)is not solving my problem.
Can someone help me correct the code in the following line
long FAR PASCAL _export ImageWndProc (HWND, UINT, UINT, LONG);
I think that is the reason why it is also giving me an error saying " huge is obsolete"
SOS
ReplyHow to use class used in my extension DLL in my VC++ Application?
Posted by Legacy on 05/12/2000 12:00amOriginally posted by: Revati
I have made an extension DLL with shared MFC support. It has COM support also as I have imported msado15.dll in it.
Now I want to use this DLL in my application. But whenever I #include .h files in my application or try to import my DLL in my stdafx.h compiler gives me DLL not found error. I have corretly included DLL in Systems directory and .lib file in project settings.
If anybody has solution to this please mail me.
Thanking you all in advance.
ReplyLoading, Please Wait ...