【问题标题】:libprotoc compiling protoc files but not other protoc included in it (google grpc assistant annotations.pb.h no file or directory error)libprotoc 编译 protoc 文件,但不编译其中包含的其他 protoc(google grpc assistant annotations.pb.h no file or directory error)
【发布时间】:2017-12-12 13:15:16
【问题描述】:

我正在尝试用 C++ 生成 Google Assistant 库。 我已经使用 protoc 编译器编译了 embedded_assistant.proto 文件并获得了 embedded_assistant.grpc.pb.hembedded_assistant.grpc.pb.cc图书馆的文件。 我创建了一个客户端文件 ea_main.cc 并将这些文件包含在其中。

当我尝试使用 g++ 编译器编译 ea_main.cc 时出现此错误。

car@ubuntu:~/grpc/examples/cpp/embedded_assistant$ g++ -I./ ea_main.cc -o OUT_CPP_TEST -std=c++11
In file included from embedded_assistant.grpc.pb.h:22:0,           
                 from ea_main.cc:9:
embedded_assistant.pb.h:33:39: fatal error: google/api/annotations.pb.h: No such file or directory
compilation terminated.

embedded_assistant.proto 文件中有另一个 proto 文件包含在其中

import "google/api/annotations.proto";
import "google/rpc/status.proto";

似乎 protoc 没有为这些 .proto 文件编译或生成标头。在 google/api/ 中查看时,它们并不存在。

这就是为什么 g++ 编译器会为缺少的 annotations.pb.h 文件提供错误。

为什么 protoc 没有编译包含在 embedded_assistant.proto 中的 proto ?我怎样才能得到这些文件? 有什么问题吗?

【问题讨论】:

    标签: compiler-errors g++ protocol-buffers google-assistant-sdk protoc


    【解决方案1】:

    我得到了解决方案,即在编译时包含其他所需的原型:-

    protoc --proto_path=protos --cpp_out=. protos/embedded_assistant.proto protos/google/api/annotations.proto protos/google/api/http.proto protos/google/rpc/status.proto
    

    【讨论】:

      猜你喜欢
      • 2019-01-24
      • 2020-03-03
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 2021-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多