1

Is there an API to know gRPC/protobuf version or the git commit hash? We would like to include these in --version information of our C++ application.

The files gRPC-Core.podspec, gRPC-C++.podspec, Protobuf-C++.podspecetc. do have this information; wonder if the same can be extracted without having to parse these files.

Curious
  • 2,783
  • 3
  • 29
  • 45

1 Answers1

0

gRPC exposes the version in its API:

const GRPCAPI char* grpc_version_string ( void )

For the C++ implementation there appears to be the following method in the <grpcpp/grpcpp.h> header:

std::string grpc::Version()

For protobuf the macro GOOGLE_PROTOBUF_VERSION is the integer value of its version & can be converted to string using the following API:

std::string google::protobuf::internal::VersionString(int version)

Curious
  • 2,783
  • 3
  • 29
  • 45
Kiskae
  • 24,655
  • 2
  • 77
  • 74
  • thanks but I think this API gives the version string for gRPC core, it is from `src/core/lib/surface/version.cc`: `const char* grpc_version_string(void) { return "10.0.0"; }` I am looking for the version of c++ library of gRPC, e.g. for https://github.com/grpc/grpc/releases/tag/v1.30.2 I expect this to be 1.30.2 – Curious Aug 03 '20 at 07:32
  • After looking through the templates I added the version exposed by ``, which appears to be what you're looking for. – Kiskae Aug 03 '20 at 09:28