title: Unable to initialize static map in class
body: <p>I am trying to initialise a static map of <br/>
  <code>map&lt;string, int&gt;</code><br/> in my program as follows:</p>
  
  <p><strong>testApp.h</strong></p>
  
  <pre><code>class testApp(){
  public:
  void setup();
  void update();
  void renew();
  static map&lt;string, int&gt; _someMap;
  };
  </code></pre>
  
  <p><strong>testApp.cpp</strong></p>
  
  <pre><code>testApp::setup(){
     _someMap["something"] = 1;
     _someMap["something2"] = 2;
  cout&lt;&lt;_someMap["something"]&lt;&lt;"\n";
  }
  </code></pre>
  
  <p>I don't want to use <code>boost</code> for this short use of map and add source dependency for my code. I am not on <code>C++11</code> and I don't have the constructor here in the program since the class is some framework's class. I am on Xcode and on doing the above in <code>.cpp</code>, I get the following error:</p>
  
  <pre><code>Undefined symbols for architecture i386:
    "testApp::mapppp", referenced from:
        testApp::setup() in testApp.o
  ld: symbol(s) not found for architecture i386
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>
  
  <p>-- >Additionally, let's say my map is private, for which I tried doing this in my class:<br/> </p>
  
  <pre><code>...
  private:
  static someVariable;
  static void someFunction();
  </code></pre>
  
  <p><strong>.cpp</strong></p>
  
  <pre><code>testApp::setup(){
  someFunction();
  }
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>Undefined symbols for architecture i386:
    "testApp::_someMap", referenced from:
        testApp::someFunction() in testApp.o
  ld: symbol(s) not found for architecture i386
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  </code></pre>