title: c++ duplicate symbol linker error when sharing a variable in a namespace
body: <p>Still relatively new to C++</p>
  
  <p>I have a header variable with a namespace with a few constants that looks something like this</p>
  
  <pre><code>namespace blah {
      const std::string x="foo";
  }
  </code></pre>
  
  <p>I have no problems accessing the variables this way - dosomething(blah::x); etc. Now I want to change the variable so it can be modified. If I just take out the const I get a linker error "duplicate symbol blah::x". Adding an extern here doesn't help:</p>
  
  <pre><code>namespace blah {
      extern std::string x;
  } 
  </code></pre>
  
  <p>It says that extern is enabled by default and I get the same duplicate symbol error. Whats the right way to do this?</p>
  
  <p>(EDIT in the latter case, I don't want to set the variable value yet. I want to derive it elsewhere and share the value. To clarify - I want to get rid of the const so I can change the value (e.g. using command line arguments. When I get rid of the const is when I get the errors about duplicate symbols.)</p>