title: symbol lookup error
body: <p>I am writing a shared library with C++ under Ubuntu. The source code contains two files: ClassA.h and ClassA.cpp. Bellow are parts of the contents:</p>
  
  <p>ClassA.h:</p>
  
  <pre><code>namespace calss_a{
  class ClassA{
  public:
     ...
     void foo(int nBlockIndex);
     ...
  }
  }
  </code></pre>
  
  <p>ClassA.h:</p>
  
  <pre><code>namespace calss_a{
      ...
     void classA::foo(int nBlockIndex){printf("....");}
      ...
  }
  </code></pre>
  
  <p>The compiled .so file from the above source codes is used in test.cpp as follows:</p>
  
  <pre><code>...
  class_a::ClassA * ptr = new class_a::ClassA();
  ...
  ptr-&gt;foo(0);
  ...
  </code></pre>
  
  <p>However, when the executable build from test.cpp runs, there is an error as follows:</p>
  
  <p>symbol lookup error: /home/hzhu/test: undefined symbol: _ZN16class_a15ClassA16fooEj</p>
  
  <p>But if I change in ClassA.cpp and ClassA.h the type of foo()'s argument "nBlockIndex" from "int" to "unsigned in", and recompile the .so file, then the problem disappears. In a further experiment, the argument "nBlockIndex"'s type is still defined to be "int", but in test.cpp I call "foo" this way: </p>
  
  <pre><code>ptr-&gt;foo(1); //pass 1 instead of 0
  </code></pre>
  
  <p>then the problem disappear as well.</p>
  
  <p>Can anyone tell me what is going on here?</p>
  
  <p>Thanks.</p>