I have a legacy application using proto2 with libprotobuf2.x. There is another application application that I would like this application to talk to with proto3.
I checked on possible solutions and the discussion in this thread says that libprotobuf3.x provides compatibility with proto2.
Does this mean that I can use the same proto(with proto2) and the same code stubs pb.h/pb.cpp generated for proto2 and just link my legacy application with libprotobuf3.x instead and it would work like a charm?
I don't want to update legacy protos to proto3 as it might require major refactoring in the legacy code.
No, you can't link
.pb.*
files generated withprotoc
2.0 againstlibprotobuf
3.0. Just like with any shared library, an increment in the major version number means a breaking API change.Compatibility with
proto2
means that Proto 2 syntax is supported (syntax = "proto2"
). Alsoproto3
is binary-compatible withproto2
on the wire.Chances are, if you re-generate your
.pb
files withprotoc
3 and recompile, it'll work without refactoring (the default syntax is still proto2).