1 2# Overview 3 4A C++ implementation of gRPC 5 6# To start using gRPC C++ 7 8In the C++ world, there's no universally accepted standard for managing project dependencies. 9Therefore, gRPC supports several major build systems, which should satisfy most users. 10 11## bazel 12 13We recommend using Bazel for projects that use gRPC as it will give you the best developer experience 14(easy handling of dependencies that support bazel & fast builds). 15 16To add gRPC as a dependency in bazel: 171. determine commit SHA for the grpc release you want to use 182. Use the [http_archive](https://docs.bazel.build/versions/master/be/workspace.html#http_archive) bazel rule to include gRPC source 19 ``` 20 http_archive( 21 name = "com_github_grpc_grpc", 22 urls = [ 23 "https://github.com/grpc/grpc/archive/YOUR_GRPC_COMMIT_SHA.tar.gz", 24 ], 25 strip_prefix = "grpc-YOUR_GRPC_COMMIT_SHA", 26 ) 27 28 load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps") 29 30 grpc_deps() 31 ``` 32 33NOTE: currently bazel is only supported for building gRPC on Linux. 34 35## make 36 37Currently the default choice for building on UNIX based systems is `make`. 38 39To install gRPC for C++ on your system using `make`, follow the [Building gRPC C++](../../BUILDING.md) 40instructions to build from source and then install locally using `make install`. 41This also installs the protocol buffer compiler `protoc` (if you don't have it already), 42and the C++ gRPC plugin for `protoc`. 43 44WARNING: After installing with `make install` there is no easy way to uninstall, which can cause issues 45if you later want to remove the grpc and/or protobuf installation or upgrade to a newer version. 46 47## cmake 48 49`cmake` is the default build option on Windows, but also works on Linux, MacOS. `cmake` has good 50support for crosscompiling and can be used for targeting Android platform. 51 52If your project is using cmake, there are several ways to add gRPC dependency. 53- install gRPC via cmake first and then locate it with `find_package(gRPC CONFIG)`. [Example](../../examples/cpp/helloworld/CMakeLists.txt) 54- via cmake's `ExternalProject_Add` using a technique called "superbuild". [Example](../../examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt) 55- add gRPC source tree to your project (preferrably as a git submodule) and add it to your cmake project with `add_subdirectory`. [Example](../../examples/cpp/helloworld/CMakeLists.txt) 56 57## Packaging systems 58 59There's no standard packaging system for C++. We've looked into supporting some (e.g. Conan and vcpkg) but we are not there yet. 60Contributions and community-maintained packages for popular packaging systems are welcome! 61 62 63## Examples & Additional Documentation 64 65You can find out how to build and run our simplest gRPC C++ example in our 66[C++ quick start](../../examples/cpp). 67 68For more detailed documentation on using gRPC in C++ , see our main 69documentation site at [grpc.io](https://grpc.io), specifically: 70 71* [Overview](https://grpc.io/docs/): An introduction to gRPC with a simple 72 Hello World example in all our supported languages, including C++. 73* [gRPC Basics - C++](https://grpc.io/docs/tutorials/basic/c.html): 74 A tutorial that steps you through creating a simple gRPC C++ example 75 application. 76* [Asynchronous Basics - C++](https://grpc.io/docs/tutorials/async/helloasync-cpp.html): 77 A tutorial that shows you how to use gRPC C++'s asynchronous/non-blocking 78 APIs. 79 80 81# To start developing gRPC C++ 82 83For instructions on how to build gRPC C++ from source, follow the [Building gRPC C++](../../BUILDING.md) instructions. 84