exporting global from EXE to DLL?

x66u used Ask the Experts™
Hi all,

I need to export a (dare I say) global variable from my EXE
to a DLL, but Visual Studio's linker seems to be blocking
this. Am I right in deducing that globals must be put
in a DLL and imported into DLLs and EXE from there? I am guessing
that the linker requires that info about the variable to be
in a .lib for it to be importable. In order to try the import,
I am using __declspec(dllimport) in the DLL, but the linker says it
assumes I really mean dllexport and is changing it to that,
then printing errors.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

 Create a seperate .lib  put your global in it

 then in your DLL and Exe

 extern g_blah;

 put the .lib on the link line for both.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial