C++ static linking of ONNX results in conflicts with existing symbols
See original GitHub issueWe are trying to implement an ONNX importer for a C++ runtime. Our runtime will be used by frontend applications, which also use ONNX models.
When trying to execute a process which runs both frontend and backend components, we are seeing errors indicating that a Protocol Buffers symbol name conflicts with the existing symbol.
[libprotobuf ERROR google/protobuf/descriptor_database.cc:109] Symbol name "onnx.AttributeProto" conflicts with the existing symbol "onnx.AttributeProto".
[libprotobuf FATAL google/protobuf/descriptor.cc:1164] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
Aborted (core dumped)
Did anyone already run into this problem? Have you found a good solution to this issue?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
c++ - Static linking of Protocol Buffers results in conflicts with ...
When trying to execute a process which runs both frontend and backend components, we are seeing errors indicating that a symbol name conflicts...
Read more >Static linking of Protocol Buffers results in conflicts with ...
Coding example for the question Static linking of Protocol Buffers results in conflicts with existing symbols-C++.
Read more >TensorRT 8.4.1 Release Notes - NVIDIA Documentation Center
When the TensorRT static library was used to build engines and ... to build TensorRT, it may lead to symbol conflicts or undesired...
Read more >Package Details: mxnet-cuda 1.7.0-2 - AUR (en) - Arch Linux
The CUDA-10.2 pacakge in Arch Linux is statically linked to GCC-8. Mixing GCC-8 and GCC-9 compilation units may result in UB.
Read more >vocab.txt · florentgbelidji/onnx-msmarco-distilbert-base-tas-b ...
... difference acts attacks ##ov existing votes opportunity nor shop entirely trains opposite pakistan ##pa develop resulted representatives actions reality ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I would like to let you know that we eventually fixed the problem by statically linking the protobuf library into our shared object. No namespace change was required in ONNX and the client application is working fine with our library.
This will likely have problems as protobuf has a global registry based on proto file name. If you have two
.sofile that containsonnx.pb.cc, this issue will happen. The trick we do is to define a different namespace for onnx when used in third-party and rely on onnx’s CMakefile to do the symbol replacement and renaming. Here is an example:https://github.com/onnx/onnx-tensorrt/blob/fa0964e8477fc004ee2f49ee77ffce0bf7f711a9/CMakeLists.txt#L93-L97