A C++ implementation of gRPC
In the C++ world, there's no universally accepted standard for managing project dependencies. Therefore, gRPC supports several major build systems, which should satisfy most users.
We recommend using Bazel for projects that use gRPC as it will give you the best developer experience (easy handling of dependencies that support bazel & fast builds).
To add gRPC as a dependency in bazel:
http_archive( name = "com_github_grpc_grpc", urls = [ "https://github.com/grpc/grpc/archive/YOUR_GRPC_COMMIT_SHA.tar.gz", ], strip_prefix = "grpc-YOUR_GRPC_COMMIT_SHA", ) load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") grpc_deps()
NOTE: currently bazel is only supported for building gRPC on Linux.
Currently the default choice for building on UNIX based systems is make
.
To install gRPC for C++ on your system using make
, follow the Building gRPC C++ instructions to build from source and then install locally using make install
. This also installs the protocol buffer compiler protoc
(if you don't have it already), and the C++ gRPC plugin for protoc
.
WARNING: After installing with make install
there is no easy way to uninstall, which can cause issues if you later want to remove the grpc and/or protobuf installation or upgrade to a newer version.
cmake
is the default build option on Windows, but also works on Linux, MacOS. cmake
has good support for crosscompiling and can be used for targeting Android platform.
If your project is using cmake, there are several ways to add gRPC dependency.
find_package(gRPC CONFIG)
. ExampleExternalProject_Add
using a technique called “superbuild”. Exampleadd_subdirectory
. ExampleThere‘s no standard packaging system for C++. We’ve looked into supporting some (e.g. Conan and vcpkg) but we are not there yet. Contributions and community-maintained packages for popular packaging systems are welcome!
You can find out how to build and run our simplest gRPC C++ example in our C++ quick start.
For more detailed documentation on using gRPC in C++ , see our main documentation site at grpc.io, specifically:
For instructions on how to build gRPC C++ from source, follow the Building gRPC C++ instructions.