If your cmake version isn’t up-to-date, the protobuf_generate command might not yet support the -plugin option, The versions provided by cmake can lag behind (sometimes severely) the ones that come with the libraries and so, One installed by cmake, the other installed as Which is the script that provides the protobuf_generate command. So why is this happening? The reason is that there could be two versions of the protobuf cmake script installed, grpc_out: protoc-gen-grpc: Plugin failed with status code 1. Please specify a program using absolute path or make sure the program is available in your PATH system variable Protoc-gen-grpc: program not found or is not executable proto files are c++ files and create a library target with them as source files: Compiling the proto files into a libraryįor most of the time, you can just pretend that the. In the following I will only focus on the CMakeLists.txt file in the proto/ directory. This also helps with keeping all the dependencies in one place. Since the protobuf/gRPC code is shared among the client and the server, I decided to put the code into a CMake library target and then link the client and server to that library. When you look at the example project, you will see that it is split into three parts: proto files to your CMake project to automate these steps. Actually you have to run protoc twice: Once to generate the C++ files for the protobuf serialization and another time with the gRPC plugin to generate the server/client code.ĭoing this manually is error-prone and should be avoided. proto files, you will have to run the protoc compiler to convert them to C++ code. These specify not only the format of the protobuf messages that get sent by gRPC, but also the services (calls) provided by the server.Įvery time you update the. When you build gRPC clients or servers, you will specify their API in. The full example is available in my github account: gRPC CMake example Why? Now that I found the time, I want to write a bit about how to use this in your project to automatically generate C++ code from your protobuf files. A while back, I contributed plugin/grpc support to the CMake package that comes with protobuf.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |