grpcgrpc-c++

gRPC for C++ on Ubuntu - protoc-gen-grpc error


I'm trying to use gRPC for a project and keep running into the following trouble: when generating grpc headers, the manual I can see instructs to execute

/usr/src/grpc/cmake/build/third_party/protobuf/protoc --proto_path=. --grpc_out=../.build/protocol \
 --plugin=protoc_gen_grpc=/usr/src/grpc/cmake/build/grpc_cpp_plugin ./Test.proto

All referenced files and folders exist, grpc_cpp_plugin is built with cmake from gRPC sources (along with the protobuf executable), lies in the provided directory and has -x- permissions. However, running the command results in

protoc-gen-grpc: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc_out: protoc-gen-grpc: Plugin failed with status code 1.

error. This problem is observed in both Ubuntu and MinGW under Windows. The version for Windows (obtained via vcpkg) does execute the similar command successfully. The command

/usr/src/grpc/cmake/build/third_party/protobuf/protoc --proto_path=. --cpp_out=../.build/protocol ./Test.proto

executes without any problems.

Ideas about what I'm doing wrong and/or how I can obtain more detailed diagnostic and/or how I can build gRPC C++ files with some other command would be appreciated.


Solution

  • As Abel pointed out in the comments, my issue was simply a matter of attention (I wrote protoc_gen_grpc instead of protoc-gen-grpc). Still, since I went through a number of questions and articles before successfully building and using gRPC for C++, might as well summarize it here for people dealing with the same issues. (Notice the date of the post, it may become outdated in the future.)

    Documentation

    There are several instructions saying roughly the same things with minor differences. For example, Quick start recommends using CMake, but the github BUILDING.md it links says Bazel is preferable. In addition there is a separate github instruction for C++ that has platforms support table and advice for using CMake.

    gRPC for Windows (MSVC)

    gRPC for Linux (g++)