When I was making onnx2trt, some errors took place.
protobuf/include/google/protobuf/port_def.inc:74:2: error: #error PROTOBUF_DEPRECATED was previously defined
#error PROTOBUF_DEPRECATED was previously defined
^
In file included from /home/gongweibo/onnx-tensorrt-master/build/third_party/onnx/onnx/onnx_onnx2trt_onnx.pb.cc:4:0:
/home/gongweibo/onnx-tensorrt-master/build/third_party/onnx/onnx/onnx_onnx2trt_onnx.pb.h:275:30: error: ‘google::protobuf::uint8* onnx2trt_onnx::AttributeProto::InternalSerializeWithCachedSizesToArray(google::protobuf::uint8*) const’ marked final, but is not virtual
::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
How to solve this?
For C++ the version of protoc used to generate the pb.cc and pb.h files has to exactly match the version of libprotobuf you link against. It looks like your code is mixing different versions, probably an old version of the generated code with a newer version of the protobuf library.
~~I got this error because I have two proto file, one uses 'proto2' while the other uses 'proto3'. :cry: ~~
I got this error because clang-format linted my code, then fails compiling. Fixed by Disable linting pb.h/pb.cc files.
You should turn off SortIncludes: false .
(Generally you should not modify pb files, I fell to this pit because my project has already configured git pre-commit hook to lint all c++ sources. :cry: )
Most helpful comment
~~I got this error because I have two proto file, one uses 'proto2' while the other uses 'proto3'. :cry: ~~
I got this error because
clang-formatlinted my code, then fails compiling. Fixed by Disable linting pb.h/pb.cc files.You should turn off
SortIncludes: false.(Generally you should not modify pb files, I fell to this pit because my project has already configured git pre-commit hook to lint all c++ sources. :cry: )