title: How do I link to cppunit?
body: <p>I think I'm missing something really stupid here. </p>
  
  <p>I have libcppunit installed: (I'm using Ubuntu 12.04)</p>
  
  <pre><code>$ apt-cache policy libcppunit-dev 
  libcppunit-dev:
    Installed: 1.12.1-4
    Candidate: 1.12.1-4
    Version table:
   *** 1.12.1-4 0
          500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
          100 /var/lib/dpkg/status
  
  $ apt-cache policy libcppunit-1.12-1 
  libcppunit-1.12-1:
    Installed: 1.12.1-4
    Candidate: 1.12.1-4
    Version table:
   *** 1.12.1-4 0
          500 http://archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
          100 /var/lib/dpkg/status
  </code></pre>
  
  <p>And I have a simple test:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  #include &lt;cppunit/ui/text/TestRunner.h&gt;
  #include &lt;cppunit/CompilerOutputter.h&gt;
  #include &lt;cppunit/TestFixture.h&gt;
  #include &lt;cppunit/extensions/HelperMacros.h&gt;
  
  int main() {
      CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
  
      CppUnit::TextUi::TestRunner runner;
      runner.addTest(suite);
      runner.setOutputter(new CppUnit::CompilerOutputter(&amp;runner.result(), std::cerr));
  
      return runner.run() ? 0 : 1;
  }
  </code></pre>
  
  <p>And I this is the compiler output:</p>
  
  <pre><code>$ g++ -lcppunit -o test.bin test.cpp 
  /tmp/ccoQDuGC.o: In function `main':
  test.cpp:(.text+0x36): undefined reference to `CppUnit::TestFactoryRegistry::getRegistry(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  test.cpp:(.text+0x75): undefined reference to `CppUnit::TextTestRunner::TextTestRunner(CppUnit::Outputter*)'
  test.cpp:(.text+0x8b): undefined reference to `CppUnit::TestRunner::addTest(CppUnit::Test*)'
  test.cpp:(.text+0x9a): undefined reference to `CppUnit::TextTestRunner::result() const'
  test.cpp:(.text+0xe2): undefined reference to `CppUnit::CompilerOutputter::CompilerOutputter(CppUnit::TestResultCollector*, std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; const&amp;)'
  test.cpp:(.text+0xf4): undefined reference to `CppUnit::TextTestRunner::setOutputter(CppUnit::Outputter*)'
  test.cpp:(.text+0x150): undefined reference to `CppUnit::TextTestRunner::run(std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, bool, bool, bool)'
  test.cpp:(.text+0x189): undefined reference to `CppUnit::TextTestRunner::~TextTestRunner()'
  test.cpp:(.text+0x227): undefined reference to `CppUnit::TextTestRunner::~TextTestRunner()'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>To make sure, the libraries do exist under /usr/lib</p>
  
  <pre><code>$ ls /usr/lib/ | grep cppunit
  libcppunit-1.12.so.1
  libcppunit-1.12.so.1.0.0
  libcppunit.a
  libcppunit.la
  libcppunit.so
  </code></pre>
  
  <p>What am I missing that is causing this?</p>