If you link protobuf as a DLL: (1) You must link to the C runtime as a DLL, otherwise you'll end up with two copies of the C runtime, which may mean two separate heaps, among other things.
(2) All components of your application which use protocol buffers must link to the same C runtime as the protocol buffers DLL. This is true when static linking as well, but sometimes people mistakenly think that it is not true with DLLs. (3) All components of your application which use protocol buffers must use the same version of protocol buffers. The DLL binary interface is not compatible between two different versions. (4) You absolutely cannot place the protobuf DLL in a system shared directory, because it may be incompatible with other apps which use a different version of the DLL. The DLL has to stay in your application's own directory. Given these constraints, there isn't much benefit to dynamic linking for most people. Usually the advantage of using a DLL is that you can share it between multiple programs, but that is unlikely to work well with protocol buffers due to the interface version compatibility issues. Another typical reason to use DLLs is because you want to provide a "plugin" system for your application. But if all your plugins link against libprotobuf as a DLL, then they must all use the same version of protocol buffers, which is a pretty serious limitation to any plugin system. A better approach would be to statically link each plugin individually against protocol buffers; this way, each plugin has its own embedded copy and doesn't have to worry about version compatibility with other plugins. However, if you do this, then you cannot pass protocol buffer objects between plugins, since they might use different versions of the library. You can, however, pass encoded messages between plugins -- the encoding format is (obviously) compatible between versions. On Mon, Dec 21, 2009 at 5:21 PM, Soth <soth1...@yahoo.com> wrote: > Hi, > in protobuf documentation it`s stated that static linking is preferred > to dynamic because of different issues. I`d like to know what these > issues are, what i shouldnt do with the protobuf if i link with it > dynamically and how come that static linking is better. Thanks ahead. > > -- > > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to proto...@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.