title: Boost unittest framework with dynamic linking and manual setup
body: <p>I am trying to setup a boost unittest framework with dynamic linking and manual setup (Not BOOST_AUTO_TEST_CASE). I have made a trivial example to reproduce my errors:</p>
  
  <pre><code>//SomeLib.cpp
  #define BOOST_TEST_DYN_LINK
  #include "SomeLib.h"
  int getImportantNumber(){return 1729;}
  int increaseNumber(int number){return number+1;}
  
  //SomeTests.cpp
  #define BOOST_TEST_DYN_LINK
  #include &lt;boost/test/unit_test.hpp&gt;
  #include "lib/SomeLib.h"
  #include "SomeTests.h"
  using namespace boost::unit_test;
  
  void SomeTests::numberIs1729(){
      BOOST_CHECK(getImportantNumber() == 1729);
  }
  void SomeTests::increase(){
      BOOST_CHECK(increaseNumber(1) == 2);
  }
  
  //ChainedInc.cpp
  #define BOOST_TEST_DYN_LINK
  #include &lt;boost/test/unit_test.hpp&gt;
  #include "lib/SomeLib.h"
  #include "ChainedInc.h"
  using namespace boost::unit_test;
  
  void ChainedInc::incinc(){
      BOOST_CHECK(increaseNumber(increaseNumber(1)) == 3);
  }
  void ChainedInc::incincinc(){
      BOOST_CHECK(increaseNumber(increaseNumber(increaseNumber(1))) == 4);
  }
  
  //Master.cpp
  #define BOOST_TEST_DYN_LINK
  #include &lt;boost/bind.hpp&gt;
  #include &lt;boost/smart_ptr.hpp&gt;
  #include &lt;boost/test/unit_test.hpp&gt;
  #include "SomeTests.h"
  
  using namespace boost::unit_test;
  test_suite* init_unit_test_suite( int, char** )
  {
      test_suite* ts1 = BOOST_TEST_SUITE( "Suite1" );
  
      boost::shared_ptr&lt;SomeTests&gt; test1 ( new SomeTests());
      ts1-&gt;add( BOOST_TEST_CASE( boost::bind(&amp;SomeTests::numberIs1729, test1)));
      ts1-&gt;add( BOOST_TEST_CASE( boost::bind(&amp;SomeTests::increase, test1)));
  
      framework::master_test_suite().add( ts1 );
      return 0;
  }
  </code></pre>
  
  <p>When I run this code I get the following error:</p>
  
  <pre><code>/usr/bin/g++ test/ChainedInc.cpp.1.o test/Master.cpp.1.o test/SomeTests.cpp.1.o lib/SomeLib.cpp.2.o -o /home/mto/src/manualBoost/build/test/app -Wl-Bdynamic -L/usr/lib64 -lboost_unit_test_framework
  
  /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
  (.text+0x20): undefined reference to `main'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>This is usally solved by adding</p>
  
  <pre><code>#define BOOST_TEST_DYN_LINK
  </code></pre>
  
  <p>to all test files and </p>
  
  <pre><code>#define BOOST_TEST_MODULE something
  </code></pre>
  
  <p>to exactly one arbitrary test file. However the last define does not work well when the boost tests are registered manually. If I try to run my tests after using this define I get</p>
  
  <pre><code>build/test/app
  
  Test setup error: test tree is empty
  </code></pre>
  
  <p>See <a href="https://stackoverflow.com/questions/17024143/boost-test-does-not-init-unit-test-suite">Boost test does not init_unit_test_suite</a>. Is it possible to use boost manual registration and dynamic linking against boost?</p>