title: Linker error LNK2019 when linking Boost 1.51.0 dynamically in VS2010
body: <p>I'm using the boost libraries as installed by the BoostPro Computing installer. I'm using VS 2010 on a Windows 7 64-bit machine. I want to link to boost dynamically, so I selected the first two options in the installer (Multithreaded Debug DLL and Multithreaded DLL, I believe they were called). An example of some installed libs are:</p>
  
  <pre><code>boost_bzip2-vc100-mt-1_51.lib
  boost_bzip2-vc100-mt-gd-1_51.lib
  </code></pre>
  
  <p>When linking to boost in my project, I also made sure to define <code>BOOST_ALL_DYN_LINK</code>. I'm specifically using the <code>filesystem</code> toolset.</p>
  
  <p>When I turn on <code>BOOST_LIB_DIAGNOSTIC</code> I see the following messages in the build output:</p>
  
  <pre><code>1&gt;  Linking to lib file: boost_filesystem-vc100-mt-gd-1_51.lib
  1&gt;  Linking to lib file: boost_system-vc100-mt-gd-1_51.lib
  </code></pre>
  
  <p>However, those are quickly followed up by:</p>
  
  <pre><code>1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; const __thiscall boost::filesystem::path::string(void)const " (__imp_?string@path@filesystem@boost@@QBE?BV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function _main
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall boost::filesystem::path::~path(void)" (__imp_??1path@filesystem@boost@@QAE@XZ) referenced in function _main
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::filesystem::path __cdecl boost::filesystem::detail::unique_path(class boost::filesystem::path const &amp;,class boost::system::error_code *)" (__imp_?unique_path@detail@filesystem@boost@@YA?AVpath@23@ABV423@PAVerror_code@system@3@@Z) referenced in function "class boost::filesystem::path __cdecl boost::filesystem::unique_path(class boost::filesystem::path const &amp;)" (?unique_path@filesystem@boost@@YA?AVpath@12@ABV312@@Z)
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class std::codecvt&lt;wchar_t,char,int&gt; const &amp; __cdecl boost::filesystem::path::codecvt(void)" (__imp_?codecvt@path@filesystem@boost@@SAABV?$codecvt@_WDH@std@@XZ) referenced in function "public: __thiscall boost::filesystem::path::path&lt;char const [20]&gt;(char const (&amp;)[20],void *)" (??$?0$$BY0BE@$$CBD@path@filesystem@boost@@QAE@AAY0BE@$$CBDPAX@Z)
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl boost::filesystem::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;)" (__imp_?convert@path_traits@filesystem@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::filesystem::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@filesystem@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;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const &amp; __cdecl boost::system::generic_category(void)" (__imp_?generic_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'posix_category''(void)" (??__Eposix_category@system@boost@@YAXXZ)
  1&gt;main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class boost::system::error_category const &amp; __cdecl boost::system::system_category(void)" (__imp_?system_category@system@boost@@YAABVerror_category@12@XZ) referenced in function "void __cdecl boost::system::`dynamic initializer for 'native_ecat''(void)" (??__Enative_ecat@system@boost@@YAXXZ)
  </code></pre>
  
  <p>Shouldn't the <code>auto-link.hpp</code> be taking care of my linking for me? I'm not specifically requesting anything be linked to the project because the auto linker appears to be identifying everything correctly. So how is it that I'm missing these things? Also, they're declared as <code>dllimport</code>, so shouldn't the linker be leaving them alone and expect them to be discovered at runtime?</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong>: I decided to dive in on the second linker error. It's basically saying that it can't find the destructor for the <code>path</code> class. After running <code>dumpbin</code> on the <code>filesystem</code> library, I noticed that this line <em>is</em> in the file:</p>
  
  <pre><code>??1path@filesystem@boost@@QEAA@XZ (public: __cdecl boost::filesystem::path::~path(void))
  </code></pre>
  
  <p>But this obviously doesn't match with what the linker is looking for, which is this:</p>
  
  <pre><code>"__declspec(dllimport) public: __thiscall boost::filesystem::path::~path(void)" (__imp_??1path@filesystem@boost@@QAE@XZ)
  </code></pre>
  
  <p>Notice that the linker is looking for a DLL-import version, but the library itself doesn't seem to be providing one... not sure where to go from here, but it seems like important information!</p>