title: Statically link google protobuf lib into a dll library
body: <p>On the instructional page for installing and using the google protobuf library (<a href="https://github.com/google/protobuf/blob/master/cmake/README.md" rel="noreferrer">Install Protobuf On Windows</a>) it states:</p>
  
  <blockquote>
    <p>If your project is itself a DLL intended for use by third-party software, we recommend that you do NOT expose protocol buffer objects in your library's public interface, and that you <strong>statically link protocol buffers into your library</strong>.</p>
  </blockquote>
  
  <p>I am wondering how this can be accomplished. As far as i know, you can build google protobuf in 2 ways: Statically and dynamically. </p>
  
  <p>If you build it dynamiclly you will face the aformentioned problems. If you build it statically then you are using the Code generation type in Visual studio of <em>Multi-threaded (/MT)</em>. Which means in my dll lib (where it is built with <em>Multi-threaded DLL (/MD)</em>) you will get the following linker error:</p>
  
  <blockquote>
    <p>error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in Emulator.obj</p>
  </blockquote>
  
  <p>Now there are a few questions covering how to solve this:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/19575747/error-lnk2038-mismatch-detected-for-msc-ver-value-1600-doesnt-match-valu">error LNK2038: mismatch detected for &#39;_MSC_VER&#39;: value &#39;1600&#39; doesn&#39;t match value &#39;1700&#39; in CppFile1.obj</a></li>
  <li><a href="https://stackoverflow.com/questions/14714877/mismatch-detected-for-runtimelibrary">Mismatch Detected for &#39;RuntimeLibrary&#39;</a></li>
  <li>(Very similar) <a href="https://stackoverflow.com/questions/35116437/errors-when-linking-to-protobuf-3-on-msvc-2013">Errors when linking to protobuf 3 on MSVC 2013</a></li>
  </ul>
  
  <p>But the answer is commonly, change your lib to match the build type of the other library. The issue is, I don't want to do that, I want a DLL. And i want to link google protobuf statically, as described in their documentation. <strong>How can i achieve this?</strong></p>