473,498 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exporting C++ classes from a DLL

I have a class declared as ff:

class __declspec(dllexport) A {
public:
A() ;
A(const A&)
A& operator=(const A&) ;
~A() ;

void doThis(void) ;
void doThat(void) ;

private:
std::string s ;
std::vector< <std::pair> > vp ;
......
};
When I compile the code, the compiler generates several warnings such as:

warning C4251: 'A::s' : class 'std::basic_string<_Elem,_Traits,_Ax>'
needs to have dll-interface to be used by clients of class 'A'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]

etc. Why do I have to export private variables (is that what the warning
message is instructing me to do?)

Despite the warnings, the code builds and the dll is built. When I use
the dll in another project, problems (unsuprisingly) arise but they are
of a slightly different kind. One of the class methods is anoverloaded
function template method. This does not seem to be exported and I am
getting a link error when I try to link to A.lib so I can create a
project that uses classes exported by A.dll

Any pointers will be appreciated. Tks

Nov 17 '05 #1
1 1268
See : http://support.microsoft.com/kb/q168958/

--
Regards,
Nish [VC++ MVP]
http://www.voidnish.com
http://blog.voidnish.com
"Alfonso Morra" <sw***********@the-ring.com> wrote in message
news:db**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
I have a class declared as ff:

class __declspec(dllexport) A {
public:
A() ;
A(const A&)
A& operator=(const A&) ;
~A() ;

void doThis(void) ;
void doThat(void) ;

private:
std::string s ;
std::vector< <std::pair> > vp ;
......
};
When I compile the code, the compiler generates several warnings such as:

warning C4251: 'A::s' : class 'std::basic_string<_Elem,_Traits,_Ax>' needs
to have dll-interface to be used by clients of class 'A'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Ax=std::allocator<char>
]

etc. Why do I have to export private variables (is that what the warning
message is instructing me to do?)

Despite the warnings, the code builds and the dll is built. When I use the
dll in another project, problems (unsuprisingly) arise but they are of a
slightly different kind. One of the class methods is anoverloaded function
template method. This does not seem to be exported and I am getting a link
error when I try to link to A.lib so I can create a project that uses
classes exported by A.dll

Any pointers will be appreciated. Tks

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9211
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
0
1470
by: Niall | last post by:
I'm attempting to put a C# front end on my unmanaged C++ ray tracer code. It's still in experimental stage, as I have never done anything with exporting types from an unmanaged dll through to a...
7
2601
by: Gustavo L. Fabro | last post by:
Greetings! Some classes that once compiled without problems on VS 2003 have now problems on VS 2005 Beta 1. I'm talking about a __nogc class that is exported with __declspec(dllexport). The...
2
2229
by: paul | last post by:
I am exporting a class from a managed dll created in Visual C++ 2005 Express. In A.h header file I have // A.h public ref class A {}; In the same module, I create a new class to be exported...
8
1570
by: Alfonso Morra | last post by:
I am familiar with creating lean and mean WIN32 DLLS and exporting C functions via a DEF file (or cconv decorators), but I am wndering how I can export my C++ objects from my DLLs? Ideally, I...
2
2388
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
4
1621
by: =?Utf-8?B?QWw=?= | last post by:
Hello, I'm writing a service using VS2005 and C#. I've found that only the objects used as parameters in WebMethods get exported to proxy dlls and the Service Description. I'd like my service...
12
7222
by: 2b|!2b==? | last post by:
I want to export my C++ classes in a DLL, using ordinal # - rather than by name. Will anyone care to enumerate through the steps required to do this? I am already failiar with exporting classes...
15
7361
by: Grey Alien | last post by:
I have a class that contains a std::map variable. I need to export the class via a DLL. the class looks something like this: class MyClass { public: MyClass(); MyClass(const MyClass&); ...
8
3208
by: puzzlecracker | last post by:
is there a way to create a library (assembly/dll) where I can only export few class? I don't want client to use or know about other internal classes in the assembly. Thanks
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7208
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4593
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.