[RESOLVED] Global variable in a static lib
Suppose I have a global variable declared in a header file, something like this:-
Code:
extern bool myGlobalVar;
I can define and initialize the variable like this:-
Code:
bool myGlobalVar = false;
If I put that initialization into the global space for my executable, everything works fine - but if I put the initialization into the global space for a static library and then I link my executable (statically) to the lib, the linker complains about myGlobalVar being an unresolved external. Is there a way around this problem (i.e. a way of keeping the variable global - but also 'housing it' in the lib to which it belongs)
"A problem well stated is a problem half solved.” - Charles F. Kettering