title: When using built boost library in visual studio: libboost_regex-vc120-mt-sgd-1_59.lib(instances.obj) : error LNK2038: mismatch detected
body: <h2>Problem</h2>
  
  <p>I am learning the boost library for future use in my x64 console application on windows. I tried the simplest example provided here: </p>
  
  <p><a href="http://www.boost.org/doc/libs/1_59_0/more/getting_started/windows.html#prepare-to-use-a-boost-library-binary" rel="nofollow">http://www.boost.org/doc/libs/1_59_0/more/getting_started/windows.html#prepare-to-use-a-boost-library-binary</a></p>
  
  <p>I want the boost library built to meet the following conditions:</p>
  
  <ol>
  <li>for x64 platform. My console application is to deal with 3D data, so x64 is a must.</li>
  <li>can be used in visual studio both in debug mode and release mode.</li>
  <li>built as static library. My console application needs to be run on another computer.</li>
  <li>can used in multithread. I need multithread to make make my program as fast as possible.</li>
  </ol>
  
  <p>I read the instruction at that webpage and searched many other pages and tried many build command such as:</p>
  
  <pre><code>bjam --build-type=complete toolset=msvc-10.0 threading=multi link=static address-model=64
  b2 variant=release --build-type=complete architecture=x86 address-model=64 stage
  b2 runtime-link=static variant=release address-model=64
  </code></pre>
  
  <p>Finally, I built the small visual studio project successfully in x64|Debug mode. However, when I tried the Release mode I get errors like:</p>
  
  <pre><code>1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(instances.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(instances.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(regex.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(regex.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(regex_traits_defaults.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(regex_traits_defaults.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(static_mutex.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(static_mutex.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(w32_regex_traits.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(w32_regex_traits.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(regex_raw_buffer.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libboost_regex-vc120-mt-sgd-1_59.lib(regex_raw_buffer.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  
  1&gt;libcpmtd.lib(stdthrow.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '2' doesn't match value '0' in Temp.obj
  
  1&gt;libcpmtd.lib(stdthrow.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MT_StaticRelease' in Temp.obj
  
  1&gt;LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
  </code></pre>
  
  <h2>My Analysis</h2>
  
  <p>I'm using Visual Studio 2013. It seems the "sgd" in "libboost_regex-vc120-mt-sgd-1_59.lib(regex.obj)" indicates its a debug library. I searched the %BOOST_ROOT%\stage\lib. As with libboost_regex, I have:</p>
  
  <pre><code>"C:\Program Files\boost\boost_1_59_0\stage\lib\libboost_regex-vc120-s-1_59.lib"
  "C:\Program Files\boost\boost_1_59_0\stage\lib\libboost_regex-vc120-sgd-1_59.lib"
  "C:\Program Files\boost\boost_1_59_0\stage\lib\libboost_regex-vc120-mt-1_59.lib"
  "C:\Program Files\boost\boost_1_59_0\stage\lib\libboost_regex-vc120-mt-s-1_59.lib"
  "C:\Program Files\boost\boost_1_59_0\stage\lib\libboost_regex-vc120-mt-sgd-1_59.lib"
  "C:\Program Files\boost\boost_1_59_0\stage\lib\libboost_regex-vc120-mt-gd-1_59.lib"
  </code></pre>
  
  <p>I didn't specify libboost_regex-vc120-mt-sgd-1_59.lib for visual studio, it selected by visual studio automatically. So, I think I either failed to built the real required lib or I need to set the project property somehow.</p>
  
  <h2>My Question</h2>
  
  <ol>
  <li>How to make the small project built successfully in Release mode?</li>
  <li>What the difference between b2 and bjam when building boost?</li>
  </ol>