title: How to use publically exported global DLL variables?
body: <p>Say I have 2 simple classes <code>A</code> and <code>C</code>, also I have global external variables in form of pointers to <code>A</code> and <code>C</code>. Code:</p>
  
  <pre><code>//global.h
  #pragma once
  #include "A.h"
  #include "C.h"
  struct A;
  struct C;
  extern A* external_a;
  extern C* external_c;
  /////////////////////////////////////////
  //A.h
  #pragma once
  struct A {
      void get();
  };
  /////////////////////////////////////////    
  //A.cpp
  #include "A.h"
  void A::get() {}
  /////////////////////////////////////////
  //C.h
  #pragma once
  # include "global.h"
  struct C {
      void doit();
  };
  /////////////////////////////////////////   
  //C.cpp
  # include "C.h"
  void C::doit() { external_a-&gt;get(); }
  /////////////////////////////////////////
  </code></pre>
  
  <p>I listed only DLL code. The point was for DLL user to provide from (declare in) his EXE code say main.cpp global variables for my DLL code to use. So user is not in the same project while I want to use that external variables in multiple files inside my DLL project.</p>
  
  <p>I get two errors from this code regarding <code>unresolved external symbol "struct A * external_a"</code>
  <a href="https://i.stack.imgur.com/lR6wa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lR6wa.png" alt="enter image description here"></a></p>
  
  <p>I have tried to write <code>__declspec(dllexport)</code> in class defenitions and after <code>external</code> keyword. It does not help to fix the error. So I wonder what shall be done to be able to compile such project?</p>