Closed GoogleCodeExporter closed 9 years ago
The design of the protobuf library is currently such that if you unload a
dynamic
library containing a protobuf class, you *must* simultaneously unload the copy
of
libprotobuf that it is linked against. Therefore, if you are writing a dynamic
library which may be loaded and unloaded at runtime, you should probably
statically
link it against protocol buffers.
Alternatively, if you use:
option optimize_for = LITE_RUNTIME;
and you do not use extensions, then I believe this will produce code that does
not
use any global registries and thus does not have these problems.
Original comment by kenton+protobuf@google.com
on 12 Oct 2009 at 7:56
Original comment by kenton+protobuf@google.com
on 12 Oct 2009 at 7:56
[deleted comment]
I can's try the second advise set "option optimize_for = LITE_RUNTIME;" as I
need to use protobuf's descriptor and reflection,does the first advice really
works? you say "probably"
Original comment by ssj...@gmail.com
on 5 Nov 2012 at 3:01
Statically linking libprotobuf into your dynamic library will work as long as
protobufs are entirely encapsulated within your library's implementation and
not exposed in the interface. It may be a little tricky to convince gcc to
link libprotobuf statically without linking everything statically, but it
should be doable -- I think it works if you explicitly pass libprotobuf.a on
the command line instead of the usual "-lprotobuf".
Original comment by kenton@google.com
on 5 Nov 2012 at 6:54
This assert causes problems even if you do not intend to unload the dynamic
library, as it occurs on dlopen. Is it strictly necessary? Can it be replaced
with an assert when the message definitions are different?
Original comment by richardg...@gmail.com
on 1 Mar 2013 at 5:29
Original issue reported on code.google.com by
scott.m....@gmail.com
on 8 Oct 2009 at 5:40