I have a class like
class K {
static int a;
static int b;
}
I would like to create a shared library (dll) containing this class K. In the cpp file compiled in the library, I call
int K::a = 0;
int K::b = 0;
to create static variables. The dll compiles without errors, but when I use the library, I get an unresolved external character error for the K::aand members K::b. In the main program, where I want to use it, I include the same header with the class declaration K, the only difference is that for the library I use class __declspec( dllexport ) K { ... } for the main programclass K { ... }
Perhaps I am making more than one mistake, so my questions will be, how can I
- tell the linker to share the static member class in the library?
- , ?
PS. Visual Studio 2008...