使用 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,但是下面的文件(我正在使用的文件是 syntax="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.
有人有想法吗?