Exporting static data members to a DLL. 
Author Message
 Exporting static data members to a DLL.

Why doesn't the code below work for clients of my dll?
The linker complains about an unresolved external Math::M_RAD_DEG. The math
class is filled with a lot of static member methods, which do not have this
problem, is there a difference between data and function exports?

Thanks,

Sytse.

//In math.h
class _declspec(dllexport) Math:
{
public:
    static const double M_RAD_DEG;
    ...

Quote:
};

//In math.cpp
#include"Math.h"

const double Math::M_RAD_DEG = 57.2957795131;
...

//In my test app (linked with the library).
#include"Math.h"
#include<iostream.h>

int main()
{
    cout<< SomeAngle * Math::M_RAD_DEG;
    return cin.get();

Quote:
}



Thu, 21 Mar 2002 03:00:00 GMT  
 Exporting static data members to a DLL.
: Why doesn't the code below work for clients of my dll?
: The linker complains about an unresolved external Math::M_RAD_DEG. The math
: class is filled with a lot of static member methods, which do not have this
: problem, is there a difference between data and function exports?
<snip>

Unfortunately so.  You have to mark them as __declspec(dllexport) or
__declspec(dllimport) depending on whether the declaration is being used
by DLL code or by a DLL user.

--
Any opinions expressed are my own and not necessarily those of Laser-Scan.



Fri, 22 Mar 2002 03:00:00 GMT  
 Exporting static data members to a DLL.
If you are using MFC, you might also want to look at:
http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_e...
nd_import_using_afx_ext_class.htm

HTH
Markus


Quote:

>: Why doesn't the code below work for clients of my dll?
>: The linker complains about an unresolved external Math::M_RAD_DEG. The
math
>: class is filled with a lot of static member methods, which do not have
this
>: problem, is there a difference between data and function exports?
><snip>

>Unfortunately so.  You have to mark them as __declspec(dllexport) or
>__declspec(dllimport) depending on whether the declaration is being used
>by DLL code or by a DLL user.

>--
>Any opinions expressed are my own and not necessarily those of Laser-Scan.



Fri, 22 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Exporting static data members in DLL problem

2. Exporting class static data member from DLL( long )

3. Unresolved static template data member exported from DLL

4. DLLs: exported static data members...

5. dll export of static const class members

6. DLL export static members (MSDEV 6.0 Bug?)

7. Export static member variables in DLL

8. Exporting static class member from DLL

9. DLL export static members (MSDEV 6.0 Bug?)

10. static member in a dll to export

11. DLL export static members (MSDEV 6.0 Bug?)

12. Exporting static class member from DLL

 

 
Powered by phpBB® Forum Software