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

huangapple go评论96阅读模式
英文:

Unable to generate client code using proto 3.0 buffer in gRPC

问题

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

当我执行protoc时,我得到以下错误:

$ 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.

有任何想法为什么我无法生成客户端/服务器代码吗?

英文:

I am trying to generate client and server code in gRPC. I have installed grpc directory from github and trying to generate C++ code. I installed proto compiler 3.0.0.

When I am executing protoc i am getting below error

$ 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.

Any idea why I am not able to generate client/server code

答案1

得分: 3

请检查/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,请检查是否同时使用了相同版本的protoc和插件。

英文:

Check your /usr/local/bin. It should be there along with plugins for other languages.

/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*

If you do have other plugins but not cpp you probably overlooked something while installing.

If it's there try to specify full path when compiling (i.e. --plugin=protoc-gen-grpc=/usr/local/bin/grpc_cpp_plugin)

If you have multiple version of protobuf check if you use protoc and plugin from the same one.

huangapple
  • 本文由 发表于 2016年3月2日 15:13:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/35740720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定