protobuf
protobuf copied to clipboard
FileOptions multiple extension registration
I'm trying to utilize file level extension using FileOptions to version proto files.
I created following files:
Version.proto
import "google/protobuf/descriptor.proto";
extend google.protobuf.FileOptions {
string version = 50001;
}
I have two additional protos that import Version.proto and use option(version) extension:
A.proto
import "Version.proto";
option (version) = "1.0.1";
B.proto
import "Version.proto";
option (version) = "1.0.1";
My setup: Windows 10, C++ VS 2017, protobuf ver 3.4.0. All three protos are compiled by protoc.exe, the output headers & cc files are included into the project. Protobuf.dll linked dynamically.
When I run the application that uses mentioned proto files I get following error just upon startup:
[libprotobuf FATAL google\protobuf\extension_set.cc:102] Multiple extension registrations for type google.protobuf.FileOptions, field number 50001.
Duplicated from https://stackoverflow.com/questions/55627296/fileoptions-extension-in-multiple-protos
I suspect that the generated code for version.proto is somehow getting linked more than once, which would explain why the problem persists even if you choose a different extension number. Maybe there are multiple DLL's that all include version.proto's generated code?
@acozzette Good recognition. The setup looks this way: Static lib cotains proto h&cc files. It is linked to DLL and EXEC. The DLL is also linked to EXEC.
OK, I think the important thing then is just to restructure the app so that the version.proto generated code is only linked once.
The thing is the proto files are used both in DLL and EXEC. The DLL is shared by other parts of the system also. If I remove static lib containing h&cc files from EXEC or DLL they won't compile.
Is there a workaround, I am experiencing the same issue when a dynamically linked binary crashes (while the same binary linked statically works). I am hoping that linking libprotobuf dynamically everywhere would fix this, but perhaps someone can confirm?
Related to #7826
We have the similar issue and load the dynamic library twice which static link to the same protobuf generated library. It works in Linux but crashes in MacOS. It would be great to support in MacOS or we can do something for workaround.
MacOS version is 12.0.1.
Does someone have a solution for this situation? @fahhem @tobegit3hub
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.
This issue is labeled inactive because the last activity was over 90 days ago.
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.