1

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.

  • Does this answer your question? [Protobuf backward compatibility and proto3 vs proto2](https://stackoverflow.com/questions/40680273/protobuf-backward-compatibility-and-proto3-vs-proto2) – JulianW Sep 10 '20 at 15:50

1 Answers1

1

No, you can't link .pb.* files generated with protoc 2.0 against libprotobuf 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"). Also proto3 is binary-compatible with proto2 on the wire.

I don't want to update legacy protos to proto3 as it might require major refactoring in the legacy code.

Chances are, if you re-generate your .pb files with protoc 3 and recompile, it'll work without refactoring (the default syntax is still proto2).

rustyx
  • 80,671
  • 25
  • 200
  • 267