title: Multiple definitions of a static variable of a templated class
body: <p>I have a templated class called <code>PooledResource</code>. It handles loading things like textures and sounds for me and ensures that I don't load the same one multiple times on accident. Resources of a certain type will always be in a certain subdirectory, and I wanted to make it easier to load them, so I decided to add a static variable that keeps track of the root folder for a certain type of resource. </p>
  
  <pre><code>template &lt;typename T&gt;
  class PooledResource
  {
  public:
      // ...
  
      static const char* PathPrefix;
      static ResourceTable myResourceTable;
  
  
      static void load(const char* filename)
      {
          // Any attempt to use PathPrefix in here causes a compilation error
          // All I want to do is use PathPrefix and filename to get the full
          // path do a file and load it. 
      }
  };
  
  template &lt;typename T&gt;
  const char* PooledResource&lt;T&gt;::PathPrefix = NULL;
  
  template &lt;typename T&gt;
  typename PooledResource&lt;T&gt;::ResourceTable PooledResource&lt;T&gt;::myResourceTable;
  </code></pre>
  
  <p>The idea is that I can use a typedef'd version of this for various types. For example, in <code>PooledTexture.hpp</code> I would have:</p>
  
  <pre><code>typedef PooledResource&lt;Texture&gt; PooledTexture;
  </code></pre>
  
  <p>and in <code>PooledTexture.cpp</code> I would have:</p>
  
  <pre><code>template &lt;&gt;
  const char* PooledTexture::PathPrefix = "../assets/textures/";
  </code></pre>
  
  <p>This will all compile and run fine if I don't attempt to use PathPrefix in the load function above. As soon as I use it though, I get errors like this:</p>
  
  <pre><code> 90 || CMakeFiles/game.dir/PooledTexture.cpp.o:(.data+0x0): multiple definition of `ag::PooledResource&lt;sf::Texture&gt;::PathPrefix'
   91 CMakeFiles/game.dir/lua/LuaFrame.cpp.o:/usr/include/c++/4.6/i686-linux-gnu/./bits/gthr-default.h|241| first defined here
  </code></pre>
  
  <p>I've tried reproducing this with a simpler case to try to hunt down the problem, but other cases I try seem to work. I'm not sure what I'm doing differently here that would cause this error. </p>