Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Linux gRPC & Conan Version incompatibility

I am trying to use gRPC to create a simple rpc mechanism for a project. I started by cloning gRPC from github and selecting the tag for version 1.47.1.

I built and installed this on Ubuntu as per the instructions, by pulling from GitHub and selecting the tag for v1.47.1

I then created a simple file, e.g.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

// Latest proto standard
syntax = "proto3";

package packageName;

// TODO Define service name
service ConfigService {
    rpc GET (GetRequest) returns (GetResponse);
}

message GetRequest {
    string id = 1;
}

message GetResponse {
    string value = 1;
}

Next step is to generate the C++ code

GEN_GRPC_SERVER_DIR=./gen_grpc_server_base
GEN_GRPC_MESSAGE_DIR=./gen_grpc_message_defs
mkdir -p $GEN_GRPC_SERVER_DIR $GEN_GRPC_MESSAGE_DIR
protoc --proto_path=. --cpp_out=$GEN_GRPC_MESSAGE_DIR \
        --grpc_out=$GEN_GRPC_SERVER_DIR \
        --plugin=protoc-gen-grpc=/usr/bin/grpc_cpp_plugin \
        ./simple.proto

I am using CMake with Conan to build. My conanfile.txt includes the line:
grpc/1.47.1

Unfortunately when I try and build it using CMake with Conan I get an error about versioning. Which is triggered by the following generated code:

#include <google/protobuf/port_def.inc>
#if PROTOBUF_VERSION < 3019000
#error This file was generated by a newer version of protoc which is
#error incompatible with your Protocol Buffer headers. Please update
#error your headers.
#endif
#if 3019004 < PROTOBUF_MIN_PROTOC_VERSION
#error This file was generated by an older version of protoc which is
#error incompatible with your Protocol Buffer headers. Please
#error regenerate this file with a newer version of protoc.
#endif

When I checked the file port_def.inc in the clone of grpc from github it shows that the version is 301900

When I check the version reported from the file port_def.inc from my ~/.conan/data/grpc directory is 3021000 hence the error message.

I assumed the version would match because my Conan file states the version as 1.47.1 and the tag of gRPC from GitHub I selected is v1.47.1.

Further investigation of the GitHi clone reveals that the file port_def.inc comes from the the submodule for protobuf. The tag for protobuf that has a version of port_def.inc whcih has the correct version is tagged v3.21.0 which is not the version used by gRPC v1.47.1

How do I pull and build a version of gRPC from GitHub which matches the version used by Conan? or is there a better approach?

>Solution :

You can either override the protobuf version in your conan recipe to 3.19.4 or probably better to update the git submodule in grpc/third_party/protobuf to 3.21.0:

cd grpc/third_party/protobuf
git checkout v3.21.0
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading