title: Link error with my own C++ library
body: <p>This is my first time trying to make a simple library. I worked in Ubuntu 12.04 with g++ 4.6.3. Here is the problem:</p>
  
  <pre><code>[[mylib.cpp]]
  #include&lt;sqlite3.h&gt;
  void Mylib::blahblah() {...}
  void Mylib::evenmoreblah() {...}
  ...
  
  [[mylib.h]]
  #include &lt;...&gt;
  class Mylib {
      ...
  };
  </code></pre>
  
  <p>Then I made the lib by:</p>
  
  <pre><code> gcc -c -Wall -fpic mylib.cpp
   gcc -shared -o libmylib.so mylib.o
  </code></pre>
  
  <p>I used the library in a single test.cpp which contains only the main(). I put libmylib.so in ./libdir, and compiled by using:</p>
  
  <pre><code> g++ -g test.cpp -o test -lpthread -L/usr/local/lib -lsqlite3 -L./libdir -lmylib
  </code></pre>
  
  <p>The error I got:</p>
  
  <pre><code>./libdir/libmylib.so: undefined reference to `sqlite3_close'
  ./libdir/libmylib.so: undefined reference to `sqlite3_exec'
  ./libdir/libmylib.so: undefined reference to `sqlite3_free'
  ./libdir/libmylib.so: undefined reference to `sqlite3_open'
  </code></pre>