title: What could be causing this linker error?
body: <p>I been trying to resolve this <code>unresolved external symbol</code> on a static variable for hours now, and I'm at my wits' end. I'm using Visual Studio 2010. Here's a simplified overview of the situation:</p>
  
  <p>Projects in question:</p>
  
  <pre><code>-ProjA (outputs a .dll and .lib)
  -ProjB (outputs a .exe)
  </code></pre>
  
  <p>In ProjA, I have these two files:</p>
  
  <pre><code>//foo.h
  #pragma once
  
  class SUP
  {
  public: 
      static int staticint;
  };
  </code></pre>
  
  <p>and</p>
  
  <pre><code>//foo.cpp
  #include "foo.h"
  int SUP::staticint = 10;
  </code></pre>
  
  <p>ProjB links to ProjA.lib</p>
  
  <pre><code>//main.cpp
  #include "{Full_Path}foo.h"
  int main(){
     std::cout &lt;&lt; SUP::staticint &lt;&lt; std:: endl;
  }
  </code></pre>
  
  <p>Now, main.cpp compiles without any problems, but when I try to build the project, I get the following error:</p>
  
  <p><code>main.obj : error LNK2001: unresolved external symbol "public: static int SUP::staticint" (?staticint@SUP@@2HA)</code></p>
  
  <p>I'm almost 100% certain I've set up ProjB's options correctly. Under "Additional Dependencies" all I have "ProjA.lib", and under "Additional Library Directories" I have the path to the directory where the ProjA.lib file is generated.</p>
  
  <p>I've even had ProjA output a .map file, and in the map I find:
  <code>0003:00004458       ?staticint@SUP@@2HA               10049458     foo.obj</code></p>
  
  <p>So I'm guessing that it means that <code>staticint</code> has been defined correctly.</p>
  
  <p>What could possibly be going wrong? Obviously, I'm doing something wrong, but I fail to see what. I've made sure that ProjB is linking with the correct .lib file. I've made sure the include directories are good. I've made sure that the definition of the static variable is sound. I will provide any other information if necessary.</p>