title: Linker error while compiling mongo db client example on Windows
body: <p>I have a linker problem while compiling mongo db client example on Windows. I'm using Visual Studio 2012. </p>
  
  <p>I'm trying to compile <a href="https://github.com/mongodb/mongo/blob/master/src/mongo/client/examples/clientTest.cpp" rel="nofollow noreferrer">src\mongo\client\examples\clientTest.cpp</a> from mongo's git.</p>
  
  <p>I did following steps:</p>
  
  <ul>
  <li>Built Boost v1.51 using bjam2. I'm using it on another project so I know binaries are good.</li>
  <li>Built MongoDB C++ driver as <code>scons --dd mongoclient.lib</code></li>
  <li>Included boost include directory in my project as an Additional Include Directory.</li>
  <li>Define  _CRT_SECURE_NO_WARNINGS to avoid warnings on use of strncpy and such by the MongoDB client code.</li>
  <li>Include the boost (binary) libraries directory to the project.</li>
  </ul>
  
  <p>Still, I get following errors</p>
  
  <pre><code>1&gt;mongoclient.lib(log.obj) : error LNK2019: unresolved external symbol "void __cdecl boost::filesystem3::path_traits::convert(char const *,char const *,class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt; &amp;,class std::codecvt&lt;wchar_t,char,int&gt; const &amp;)" (?convert@path_traits@filesystem3@boost@@YAXPBD0AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ABV?$codecvt@_WDH@5@@Z) referenced in function "void __cdecl boost::filesystem3::path_traits::dispatch&lt;class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt; &gt;(class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const &amp;,class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt; &amp;,class std::codecvt&lt;wchar_t,char,int&gt; const &amp;)" (??$dispatch@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@path_traits@filesystem3@boost@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@4@ABV?$codecvt@_WDH@4@@Z)
  1&gt;mongoclient.lib(log.obj) : error LNK2019: unresolved external symbol "private: static class std::codecvt&lt;wchar_t,char,int&gt; const * &amp; __cdecl boost::filesystem3::path::wchar_t_codecvt_facet(void)" (?wchar_t_codecvt_facet@path@filesystem3@boost@@CAAAPBV?$codecvt@_WDH@std@@XZ) referenced in function "public: static class std::codecvt&lt;wchar_t,char,int&gt; const &amp; __cdecl boost::filesystem3::path::codecvt(void)" (?codecvt@path@filesystem3@boost@@SAABV?$codecvt@_WDH@std@@XZ)
  1&gt;mongoclient.lib(log.obj) : error LNK2019: unresolved external symbol "class boost::filesystem3::file_status __cdecl boost::filesystem3::detail::status(class boost::filesystem3::path const &amp;,class boost::system::error_code *)" (?status@detail@filesystem3@boost@@YA?AVfile_status@23@ABVpath@23@PAVerror_code@system@3@@Z) referenced in function "bool __cdecl boost::filesystem3::exists(class boost::filesystem3::path const &amp;)" (?exists@filesystem3@boost@@YA_NABVpath@12@@Z)
  1&gt;mongoclient.lib(background.obj) : error LNK2019: unresolved external symbol "public: __thiscall boost::thread::~thread(void)" (??1thread@boost@@QAE@XZ) referenced in function "public: class mongo::BackgroundJob &amp; __thiscall mongo::BackgroundJob::go(void)" (?go@BackgroundJob@mongo@@QAEAAV12@XZ)
  </code></pre>
  
  <p>So it looks like it ignores <code>#pragma comment lib</code> directives in boost's headers.</p>
  
  <p>I tried explicitly adding <code>libboost_thread-vc110-mt-sgd-1_51.lib</code> in <code>Linker/Input</code> tab of project settings. It didn't help.</p>
  
  <p>I tried specifying <code>#pragma comment(lib, "libboost_thread-vc110-mt-sgd-1_51.lib")</code> in main cpp file of the example. It didn't help either.</p>
  
  <p>But! Adding </p>
  
  <pre><code>#include &lt;boost/thread/thread.hpp&gt;
  </code></pre>
  
  <p><strong>and</strong></p>
  
  <pre><code>boost::thread _thrd(&amp;Func);
  _thrd.join();
  </code></pre>
  
  <p>at the beginning of clientTest.cpp helped to get rid of error about missing boost::thread::~thread(void). Looks like it forced linker to link to thread's lib binary.</p>
  
  <p>Unfortunately repeating this trick with <code>&lt;boost/filesystem.hpp&gt;</code> didn't help :(</p>
  
  <p>I also <a href="https://stackoverflow.com/a/4763452/226895">made sure</a> that all LIB files, of Boost and Mongo client, are compiled for 32-bit target using <code>dumpbin.exe</code>.</p>
  
  <p>What else could it be guys ?</p>
  
  <p>Thanks!</p>