title: Linking problems with std::mutex and std::atomic
body: <p>I have this:</p>
  
  <p>Singleton.h</p>
  
  <pre><code>#ifndef SINGLETON_H
  #define SINGLETON_H
  
  #include &lt;atomic&gt;
  #include &lt;mutex&gt;
  
  class Singleton
  {
  public:
      static std::atomic&lt;Singleton*&gt; Singleton::m_instance;
      static std::mutex Singleton::m_mutex;
      static Singleton* getInstance();
  
      Singleton();
      ~Singleton();
  };
  
  #endif
  </code></pre>
  
  <p>Singleton.cpp</p>
  
  <pre><code>#include "Singleton.h"
  
  Singleton::Singleton()
  {
  }
  
  Singleton* Singleton::getInstance() 
  {
      Singleton* tmp = m_instance.load(std::memory_order_relaxed);
      std::atomic_thread_fence(std::memory_order_acquire);
      if (tmp == nullptr) 
      {
          std::lock_guard&lt;std::mutex&gt; lock(m_mutex);
          tmp = m_instance.load(std::memory_order_relaxed);
          if (tmp == nullptr) 
          {
              tmp = new Singleton;
              std::atomic_thread_fence(std::memory_order_release);
              m_instance.store(tmp, std::memory_order_relaxed);
          }
      }
      return tmp;
  }
  
  Singleton::~Singleton() {}
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>#include "Singleton.h"
  #include &lt;iostream&gt;
  int main()
  {
      Singleton* singleton = Singleton::getInstance();
      std::cout &lt;&lt; "Hello World!" &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>When i try to build that i get this errors(Visual studios):</p>
  
  <blockquote>
    <p>Error 1   error LNK2001: unresolved external symbol "public: static
    struct std::atomic Singleton::m_instance"
    (?m_instance@Singleton@@2U?$atomic@PAVSingleton@@@std@@A)
    c:...Singleton.obj   Singleton</p>
  </blockquote>
  
  <p>AND:</p>
  
  <blockquote>
    <p>Error 2   error LNK2001: unresolved external symbol "public: static
    class std::mutex Singleton::m_mutex"
    (?m_mutex@Singleton@@2Vmutex@std@@A)  c:\Users\InusualZ\documents\visual
    ...Singleton.obj  Singleton</p>
  </blockquote>