Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL and static variables member .

Status
Not open for further replies.

WilliamGS

Programmer
Jan 21, 2004
54
PE
Hi, I have a DLL with a exported class using AFX_EXT_CLASS, this class has static variables member, like:

//
// MyClass.h
//
class AFX_EXT_CLASS CMyClass {
static const WORD wIdDibActual;
static const char* pszDwgName;
....
};


//
// MyClass.cpp
//
#include "stdafx.h"
#include "MyClass.h"
const WORD Chc01Const::wIdDibActual = 1000;
const char* Chc01Const::pszDwgName = "DWGNAME";

//
//
//

But, when I'm compiling the client app, it shows the error:

hcbloquefajaview.obj : error LNK2001: unresolved external symbol "public: static unsigned short const CMyClass ::wIdDibActual" (?wIdDibActual@Chc01Const@@2GB)
hcbloquefajaview.obj : error LNK2001: unresolved external symbol "public: static char const * const CMyClass ::pszDwgName" (?pszDwgName@Chc01Const@@2PBDB)
Debug/hcBloqueFaja.exe : fatal error LNK1120: 2 unresolved externals


How can I export/import static variables member in DLLs?

Thank you very much.

William G.S.
 
Not sure you can. Remember that DLL's load into another processes address space and also must be reentrant.You can have statics in the host process that can be passed to a DLL but these will need careful concurrency control as your DLL should be reentrant.Although saying that I have only used DLL's for resources and exporting extern "C" funcs. I have never put a class inside a DLL so could be wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top