title: undefined reference when using extern
body: <p>I have the following setup (hopefully this is not too bare an example):</p>
  
  <p><strong>A.h</strong></p>
  
  <pre><code>typedef std::map&lt;unsigned int, float&gt; MyClass;
  extern MyClass inst;
  </code></pre>
  
  <p><strong>A.cpp</strong></p>
  
  <pre><code>MyClass inst;
  </code></pre>
  
  <p><strong>B.h</strong></p>
  
  <pre><code>#include &lt;A.h&gt;
  void foo();
  </code></pre>
  
  <p><strong>B.cpp</strong></p>
  
  <pre><code>#include &lt;B.h&gt;
  void foo {
      inst.myClassFunc();
  }
  </code></pre>
  
  <p>Now, when I use inst in <code>B.cpp</code> I get <code>undefined reference to inst</code>. </p>
  
  <p>Any idea on how to fix this?</p>