title: How can I build a googletest unit test using the gtest_main library with Jam?
body: <p>I am trying to build a googletest unit test for a proof of concept as a new unit testing framework that we could possibly use.  In googletest, there are two ways to write a unit test: with a main, or without a main.  If you do not define a main, you can link in the gtest_main library, which includes a main() function for you, saving you some time.  In my environment, we use Jam to build binaries.  I have gotten the binary to compile with main() in my code &amp; by using the libgtest library, but I am looking for how to build it in Jam without the main.</p>
  
  <p>Base case (with a main() function):</p>
  
  <p>I am able to build a binary with this:</p>
  
  <pre><code>Main MyUnitTestBinary : MyClass.cpp ;
  LinkLibraries MyUnitTestBinary : libgtest ;
  Library libgtest : $(GTEST_DIR)/src/gtest-all.cc ;
  </code></pre>
  
  <p>Broken case (without a main() function):</p>
  
  <p>I am not able to build a binary with this.  I see many errors when I attempt to link the objects:</p>
  
  <pre><code>Main sample1_unittest : sample1.cc sample1_unittest.cc ;
  LinkLibraries sample1_unittest : gtest_main ;
  Library gtest_main : $(GTEST_DIR)/src/gtest_main.cc ;
  </code></pre>
  
  <p>I get many Linker Errors relating to undefined reference to blah.  The undefined reference seems to be coming from the testing::internal namespace, which is not part of my code.</p>
  
  <p>Any thoughts on how I can attack this, or look for more clues on the problem?</p>