I have a static library libStatic that defines a global variable like this
Header file libStatic/globals.h
:
extern int globvar;
Code file libStatic/globals.cpp
:
int globvar = 42;
The DLL libDynamic and the executable runner are using this global variable. Furtheron, libDynamic
is linked at run-time into runner (via LoadLibrary()
, GetProcAddress()
, and the works...)
I understand this will lead to globvar
being created twice, once in the heap of runner and once in the heap of libDynamic, which is of course very undesirable.
Is there a good away around this? How can I ensure that libDynamic and runner are using the same globvar
?