protoc v2.6.1应该产生“预期的”必需”,“可选”或“重复”。

时间:2018-11-15 19:45:36

标签: cmake protocol-buffers protoc proto3

使用Ubuntu 16.04和CMake,我试图从protobuf文件创建一个共享库。 CMakes protobuf_generate_cpp正在产生PROTO_SRCS和PROTO_HDRS。

我的系统上没有任何google / protobuf / *。proto文件,因此我下载了3.6.1并将其移至/ usr / local / include。我知道我使用的是proto2,而protoc是版本2,而3.6.1中的某些* .proto文件是proto3,但是下面的文件(我正在使用的文件是语法=“ proto2”),所以我认为应该没问题。

但是,我遇到了以下错误。

 $ protoc --version
libprotoc 2.6.1

[  2%] Running C++ protocol buffer compiler on models.proto
google/protobuf/descriptor.proto:439:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:439:12: Expected field name.
google/protobuf/descriptor.proto:497:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:497:12: Expected field name.
google/protobuf/descriptor.proto:498:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:498:12: Expected field name.
google/protobuf/descriptor.proto:597:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:597:12: Expected field name.
google/protobuf/descriptor.proto:620:3: Expected "required", "optional", or "repeated".
google/protobuf/descriptor.proto:620:12: Expected field name.
edk/edk_extensions.proto: Import "google/protobuf/descriptor.proto" was not found or had errors.
edk/edk_extensions.proto:15:8: ".google.protobuf.FieldOptions" is not defined.
edk/edk_extensions.proto:20:8: ".google.protobuf.MessageOptions" is not defined.
models.proto: Import "edk/edk_extensions.proto" was not found or had errors.

有人有想法吗?

1 个答案:

答案 0 :(得分:2)

descriptor.proto的最新版本声明reserved fields-以line 439为例。这是一种新语法,已反向移植到proto2语法,但是旧版本的protoc无法理解(很不稳定)。要么更新协议,要么使用您所使用的协议附带的descriptor.proto。