On the instructional page for installing and using the google protobuf library (Install Protobuf On Windows) it states:
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 statically link protocol buffers into your library.
I am wondering how this can be accomplished. As far as i know, you can build google protobuf in 2 ways: Statically and dynamically.
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 Multi-threaded (/MT). Which means in my dll lib (where it is built with Multi-threaded DLL (/MD)) you will get the following linker error:
error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in Emulator.obj
Now there are a few questions covering how to solve this:
- error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj
- Mismatch Detected for 'RuntimeLibrary'
- (Very similar) Errors when linking to protobuf 3 on MSVC 2013
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. How can i achieve this?