无法在 gRPC 中使用 proto 3.0 缓冲区生成客户端代码

Unable to generate client code using proto 3.0 buffer in gRPC

我正在尝试在 gRPC 中生成客户端和服务器代码。我已经从 github 安装了 grpc 目录并尝试生成 C++ 代码。我安装了原型编译器 3.0.0。

当我执行协议时出现以下错误

$ protoc -I ../../protos/ --grpc_out=. --plugin=protoc-gen-grpc=grpc_cpp_plugin                                                                                                                                                  ../../protos/helloworld.proto
grpc_cpp_plugin: program not found or is not executable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

知道为什么我无法生成 client/server 代码

检查你的/usr/local/bin。它应该与其他语言的插件一起存在。

/usr/local/bin > ll total 71144 -rwxr-xr-x 1 root root 12721867 Oct 23 10:44 grpc_cpp_plugin* -rwxr-xr-x 1 root root 14509678 Oct 23 10:44 grpc_csharp_plugin* -rwxr-xr-x 1 root root 13339870 Oct 23 10:44 grpc_objective_c_plugin* -rwxr-xr-x 1 root root 12569518 Oct 23 10:44 grpc_python_plugin* -rwxr-xr-x 1 root root 12393363 Oct 23 10:44 grpc_ruby_plugin*

如果你有其他插件但没有 cpp,你可能在安装时忽略了一些东西。

如果存在,请尝试在编译时指定完整路径(即 --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin

如果您有多个版本的 protobuf,请检查您是否使用同一个版本的协议和插件。