title: Undefined reference to `(anonymous namespace)::
body: <p>I have a namespace that I am currently using in two classes. When I try to compile my project, I get that error but my namespace is not anonymous! </p>
  
  <p>One of my classes looks like this:</p>
  
  <pre><code>//margin.cpp
  #include &lt;math.h&gt;
  #include "margin.h"
  #include "anotherClass.h"
  #include "specificMath.nsp.h" //My namespace
  
  double margin::doSomeMath(double a, double b){
      return specificMath::math_function1(0, 1, 0);
      // Just a simpler, random example
  } 
  </code></pre>
  
  <p>My namespace looks like this:</p>
  
  <pre><code>//specificMath.nsp.h
  #ifndef specificMath
  #define specificMath
  namespace specificMath {
       double math_function1(double, double, double);
       double math_function1(double);
       //more functions
  }
  </code></pre>
  
  <hr>
  
  <pre><code> //specificMath.nsp.cpp
   #include &lt;stdlib.h&gt;
   #include "constants.h"
   #include "specificMath.nsp.h"
  
   namespace specificMath{
       double math_function1(double a, double b, double c){
            //some code
       }
       ... more functions
   }
  </code></pre>
  
  <p>When I try to compile, it seems to compile fine, but when linking (and I've been doing "make clean" to make sure it's using the new files) I get an error saying:</p>
  
  <pre><code>margin.o: In function `margin::doSomeMath(double, double)':
  margin.cpp:(.text+0x3d): undefined reference to `(anonymous namespace)::math_function1(double, double, double)'
  </code></pre>
  
  <p>Why does it think it's an anonymous namespace? How can I fix this? </p>
  
  <p>I compile doing this:</p>
  
  <pre><code>g++ -I. -c -w *.h *.cpp
  </code></pre>
  
  <p>And then...</p>
  
  <pre><code>g++ -o myProgram *.o 
  </code></pre>