title: Linking/using .so file in another
body: <p>i have the following <code>getmacip.cpp</code> file with the following snipp code</p>
  
  <pre><code>// ...code
  
  #include "test.h"
  
  // ...code   
  
  Test obj;
  obj.printDem();
  
  // ...code
  </code></pre>
  
  <p>here is the <code>test.h</code> file</p>
  
  <pre><code>#ifndef TEST_H
  #define TEST_H
  class Test
  {
      public:
          void printDem();  
  };
  #endif
  </code></pre>
  
  <p>here is the <code>test.cpp</code> file</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void printDem()
  {
      cout &lt;&lt; "deus.ex.machina." &lt;&lt; endl;
  }
  </code></pre>
  
  <p>i am using java and c++ together via jni. i have gotten the file getmacip.cpp to work together with java and as you can see, i am trying to get the invoke the printDem() method from the getmacip.cpp file. i first compile the getmacip.cpp with the following:</p>
  
  <pre><code>g++ -fPIC -o libgetmacip.so -shared -I $JAVA_HOME/include -I $JAVA_HOME/include/linux getmacip.cpp -lc
  </code></pre>
  
  <p>this works fine. however when i do the same with test.cpp and run the program i get the error</p>
  
  <pre><code>/usr/lib/jvm/java-8-oracle/bin/java: symbol lookup error: /home/karl/workspace/sslarp/lib/libgetmacip.so: undefined symbol: _ZN4Test8printDemEv
  </code></pre>
  
  <p>i am obviously linking the files wrongly!</p>