Dealing with message name collisions between unrelated .proto files

Skip to first unread message


Sep 21, 2022, 2:18:15 PMSep 21
to Protocol Buffers

I have two different .proto files (say foo.proto and bar.proto) for different services where both use the package name internal and both define a ToService message. I need to use both protocols from the same program, but when I try to do that, I get duplicate symbol linker errors; both define internal::ToService::~ToService and other symbols in the internal:: namespace.

I would really, really prefer to not have to modify the .proto files, since my project just tries to interact with existing services. How do I tell protoc to generate code in a different namespace than internal?

Sep 23, 2022, 3:50:27 PMSep 23
to Protocol Buffers
Unfortunately this violates the one definition rule. That simply means you have two identical C++ classes loaded. I guess you have to resolve the package/message name for one of them.
Reply all
Reply to author
0 new messages