title: Visual Studio linker error: object specified more than once
body: <p>I'm getting 238 LNK2005 errors and I have no idea what to do. They're all similar to this one:</p>
  <blockquote>
  <p>Error LNK2005 &quot;class wxString binary::add&quot;
  (?add@binary@@3VwxString@@A) already defined in
  app.obj   C:\Users\giorg\Desktop\Visual
  Studio\wxWidgetsTest\wxWidgetsTest\expandMenu.obj 1   ikeCalculator</p>
  </blockquote>
  <p>These are the two interested files.</p>
  <p><strong>ops.h</strong></p>
  <pre><code>#pragma once
  #include &quot;wx/wx.h&quot;
  #include &lt;cmath&gt;
  #include &lt;map&gt;
  
  namespace binary {
      extern const wxString add, sub, mul, div;
  }
  namespace unary {
      extern const wxString sqrt, sin, cos, tan, arcsin, arccos, arctan;
  }
  namespace constant {
      extern const wxString pi, light_speed, avogadro_number, atomic_mass_unit, planck, gas, gravity_acceleration, golden_ratio;
  }
  
  namespace calc
  {
      extern const std::map &lt; wxString, std::function&lt;long double(long double, long double)&gt; &gt; binary;
      extern const std::map &lt; wxString, std::function&lt;long double(long double)&gt; &gt; unary;
      extern const std::map &lt; wxString, long double &gt; constant;
  }
  
  bool isBinary(wxString needle);
  bool isUnary(wxString needle);
  bool isConstant(wxString needle);
  </code></pre>
  <p><strong>ops.cpp</strong></p>
  <pre><code>#include &quot;ops.h&quot;
  
  namespace binary {
      const wxString add(L&quot;+&quot;), sub(L&quot;-&quot;);
      const wxString mul(L&quot;\u00D7&quot;), div(L&quot;\u00F7&quot;);
      const wxString pow(L&quot;^&quot;);
  }
  namespace unary {
      const wxString sqrt(L&quot;\u221A&quot;);
      const wxString sin(L&quot;sin&quot;), cos(L&quot;cos&quot;), tan(L&quot;tan&quot;);
      const wxString arcsin(L&quot;arcsin&quot;), arccos(L&quot;arccos&quot;), arctan(L&quot;tan&quot;);
  }
  namespace constant {
      const wxString pi(L&quot;\u03C0&quot;);
      const wxString light_speed(L&quot;c&quot;);
      const wxString avogadro_number(L&quot;N\u1D00&quot;);
      const wxString atomic_mass_unit(L&quot;u&quot;);
      const wxString planck(L&quot;h&quot;);
      const wxString gas(L&quot;R&quot;);
      const wxString gravity_acceleration(L&quot;g&quot;);
      const wxString golden_ratio(L&quot;\u03D5&quot;);
  }
  
  namespace calc
  {
      const std::map &lt; wxString, std::function&lt;long double(long double, long double)&gt; &gt; binary
      {
          {binary::add, [](long double a, long double b) { return a + b; }},
          {binary::sub, [](long double a, long double b) { return a - b; }},
          {binary::mul, [](long double a, long double b) { return a * b; }},
          {binary::div, [](long double a, long double b) { return a / b; }},
          {binary::pow, [](long double a, long double b) { return pow(a, b); }}
      };
  
      const std::map &lt; wxString, std::function&lt;long double(long double)&gt; &gt; unary
      {
          {unary::sqrt, [](long double n) { return sqrt(n); }},
          {unary::sin, [](long double n) { return sin(n * 3.14159265359 / 180); }},       //trasformazione da rad a gradi
          {unary::cos, [](long double n) { return cos(n * 3.14159265359 / 180); }},
          {unary::tan, [](long double n) { return tan(n * 3.14159265359 / 180); }},
          {unary::arcsin, [](long double n) { return asin(n) * 180 / 3.14159265359; } },  //trasformazione da rad a gradi
          {unary::arccos, [](long double n) { return acos(n) * 180 / 3.14159265359; } },
          {unary::arctan, [](long double n) { return atan(n) * 180 / 3.14159265359; } }
      };
  
      const std::map &lt; wxString, long double &gt; constant
      {
          {constant::pi, 3.14159265359},
          {constant::light_speed, 299792458},
          {constant::avogadro_number, 6.02214086 * pow(10, 23)},
          {constant::atomic_mass_unit, 1.67 * pow(10, -27)},
          {constant::planck, 6.626 * pow(10, -34)},
          {constant::gas, 8.314},
          {constant::gravity_acceleration, 9.80665},
          {constant::golden_ratio, 1.6180339887}
      };
  }
  
  
  bool isBinary(wxString needle)
  {
      return (calc::binary.count(needle));
  }
  
  bool isUnary(wxString needle)
  {
      return (calc::unary.count(needle));
  }
  
  bool isConstant(wxString needle)
  {
      return (calc::constant.count(needle));
  }
  </code></pre>
  <p>My Visual Studio Solution:</p>
  <p><a href="https://i.stack.imgur.com/LrEBU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LrEBU.png" alt="My Visual Studio Solution" /></a></p>