title: Global variables in C++ and CriticalSections
body: <p>I have several global critical sections that need visibility across 3 or more classes defined in 3 or more .cpp files.  They're defined in an h file as: </p>
  
  <p>GlobalCS.h</p>
  
  <pre><code>#pragma once
  #include "stdafx.h"
  extern CRITICAL_SECTION g_cs1;
  extern CRITICAL_SECTION g_cs2;
  etc...
  </code></pre>
  
  <p>In a GlobalCS.cpp they are defined</p>
  
  <pre><code>#include "stdafx.h"
  #include "GlobalCS.h"
  CRITICAL_SECTION g_cs1;
  CRITICAL_SECTION g_cs2;
  </code></pre>
  
  <p>Then in the cpp for the classes they need to work in they're included as </p>
  
  <pre><code>#include "stdafx.h"
  #include "GlobalCS.h"
  </code></pre>
  
  <p>The linker is complaining giving unresolved external in the files where the critical sections are being used.  I didn't expect this since the variables are defined as extern.  What am I doing wrong or how do I get around this?</p>
  
  <p>error LNK2001: unresolved external symbol "struct _RTL_CRITICAL_SECTION g_CS_SymbolStrPlotAccess" (?g_CS_SymbolStrPlotAccess@@3U_RTL_CRITICAL_SECTION@@A)</p>