grpc proto file genertion to c++ issue

158 views Asked by At

I generated this proto file using protoc. protoc -I=C:\proto --cpp_out=C:\proto C:\proto\test.proto

syntax = "proto3";

option java_package = "ex.grpc";

package mathtest;

// Defines the service
service MathTest {
    // Function invoked to send the request
    rpc sendRequest (MathRequest) returns (MathReply) {}
}

// The request message containing requested numbers
message MathRequest {
    int32 a = 1;
    int32 b = 2;
}

// The response message containing response
message MathReply {
    int32 result = 1;
}

The header file that generated this function:

  virtual void sendRequest(::PROTOBUF_NAMESPACE_ID::RpcController* controller,
                       const ::mathtest::MathRequest* request,
                       ::mathtest::MathReply* response,
                       ::google::protobuf::Closure* done);

when the example that I based on override this function like this:

/Status sendRequest(
        ServerContext* context,
        const MathRequest* request,
        MathReply* reply
    ) override {

What did I did wrong and how I should generate the proto file?

1

There are 1 answers

0
Alon Huber On

Update: found that need to run this command to generate grpc.pb header:

protoc -I C:\proto --grpc_out=C:\Users\alon.h\grpc.build --plugin=protoc-gen-grpc=C:\proto\grpc_cpp_plugin.exe C:\proto\test.proto

grpc_cpp_plugin.exe is needed and can be found in grpc git repository