title: C++/C Shareing global variable between 2 projects in Visual Studio
body: <p>In VS, I have a sln including 2 projects:</p>
  
  <p><strong>Project A:</strong></p>
  
  <p><strong>A.h</strong></p>
  
  <pre><code>#include &lt;string&gt;
  extern bool flag;    
  </code></pre>
  
  <p><strong>A.cpp</strong></p>
  
  <pre><code>#include "A.h"
  bool flag = false;
  
  void funcA()
  {
    int i = 0;
  }
  </code></pre>
  
  <p><strong>Project B:</strong></p>
  
  <p><strong>B.h</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  </code></pre>
  
  <p><strong>B.cpp</strong></p>
  
  <pre><code>#include "B.h"
  #include "..\ProjectA\A.h"
  
  void main()
  {
      int j = 10;
      flag  = true;
      std::cout &lt;&lt; j &lt;&lt; "\n" &lt;&lt; flag ;
  }
  </code></pre>
  
  <p>I set projectA as DLL, projectB as EXE. </p>
  
  <p>In linking, I get the error:  error LNK2001: unresolved external symbol "bool flag" (?flag@@3_NA)</p>
  
  <p>Should I manually specify projectB to projectA in setting?</p>
  
  <p>Thank you.</p>