【问题标题】:Problem with GRPC generating client and server code on Windows 10 after installing with VCPKG使用 VCPKG 安装后 GRPC 在 Windows 10 上生成客户端和服务器代码的问题
【发布时间】:2021-04-27 13:24:53
【问题描述】:

我在为 GRPC 服务生成客户端和服务器代码时遇到问题。我正在调整grpc.io 的说明。

有一个 protobuf 文件 test_interface.proto 定义了我的服务,我尝试使用以下两个命令构建它,在与此文件相同的路径中运行:

protoc -I . --grpc_out=. --plugin=protoc-gen-grpc="C:\vcpkg\packages\grpc_x64-windows\tools\grpc\grpc_cpp_plugin" ./test_interface.proto
protoc -I . --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin ./test_interface.proto

两者都会导致错误:

--grpc_out: protoc-gen-grpc: The system cannot find the file specified.

我在 Windows 10 上并使用 vcpkg 安装了 grpc v1.33.1。这会安装开发依赖项,但不会将它们的二进制文件添加到系统路径中。我已手动将protocgrpc_cpp_plugin 的位置添加到路径中。

我不清楚它找不到哪个文件,之前在test_interface.proto 中发现了一些语法错误,所以我知道这个文件可以正常打开。我也可以毫无问题地从命令行运行grpc_cpp_plugin

有谁知道为什么无法构建客户端和服务器代码?

【问题讨论】:

    标签: c++ windows-10 grpc vcpkg


    【解决方案1】:

    确保将 .exe 添加到您的插件路径,如下所示:C:\vcpkg\packages\grpc_x64-windows\tools\grpc\grpc_cpp_plugin.exe

    在我们的文档中对此进行了说明: https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.compiler.plugin

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-05
      • 2022-01-12
      相关资源
      最近更新 更多