1*cc02d7e2SAndroid Build Coastguard WorkergRPC C++ - Building from source 2*cc02d7e2SAndroid Build Coastguard Worker=========================== 3*cc02d7e2SAndroid Build Coastguard Worker 4*cc02d7e2SAndroid Build Coastguard WorkerThis document has detailed instructions on how to build gRPC C++ from source. Note that it only covers the build of gRPC itself and is meant for gRPC C++ contributors and/or power users. 5*cc02d7e2SAndroid Build Coastguard WorkerOther should follow the user instructions. See the [How to use](https://github.com/grpc/grpc/tree/master/src/cpp#to-start-using-grpc-c) instructions for guidance on how to add gRPC as a dependency to a C++ application (there are several ways and system-wide installation is often not the best choice). 6*cc02d7e2SAndroid Build Coastguard Worker 7*cc02d7e2SAndroid Build Coastguard Worker# Pre-requisites 8*cc02d7e2SAndroid Build Coastguard Worker 9*cc02d7e2SAndroid Build Coastguard Worker## Linux 10*cc02d7e2SAndroid Build Coastguard Worker 11*cc02d7e2SAndroid Build Coastguard Worker```sh 12*cc02d7e2SAndroid Build Coastguard Worker $ [sudo] apt-get install build-essential autoconf libtool pkg-config 13*cc02d7e2SAndroid Build Coastguard Worker``` 14*cc02d7e2SAndroid Build Coastguard Worker 15*cc02d7e2SAndroid Build Coastguard WorkerIf you plan to build using CMake 16*cc02d7e2SAndroid Build Coastguard Worker```sh 17*cc02d7e2SAndroid Build Coastguard Worker $ [sudo] apt-get install cmake 18*cc02d7e2SAndroid Build Coastguard Worker``` 19*cc02d7e2SAndroid Build Coastguard Worker 20*cc02d7e2SAndroid Build Coastguard WorkerIf you are a contributor and plan to build and run tests, install the following as well: 21*cc02d7e2SAndroid Build Coastguard Worker```sh 22*cc02d7e2SAndroid Build Coastguard Worker $ # clang and LLVM C++ lib is only required for sanitizer builds 23*cc02d7e2SAndroid Build Coastguard Worker $ [sudo] apt-get install clang libc++-dev 24*cc02d7e2SAndroid Build Coastguard Worker``` 25*cc02d7e2SAndroid Build Coastguard Worker 26*cc02d7e2SAndroid Build Coastguard Worker## MacOS 27*cc02d7e2SAndroid Build Coastguard Worker 28*cc02d7e2SAndroid Build Coastguard WorkerOn a Mac, you will first need to 29*cc02d7e2SAndroid Build Coastguard Workerinstall Xcode or 30*cc02d7e2SAndroid Build Coastguard Worker[Command Line Tools for Xcode](https://developer.apple.com/download/more/) 31*cc02d7e2SAndroid Build Coastguard Workerand then run the following command from a terminal: 32*cc02d7e2SAndroid Build Coastguard Worker 33*cc02d7e2SAndroid Build Coastguard Worker```sh 34*cc02d7e2SAndroid Build Coastguard Worker $ [sudo] xcode-select --install 35*cc02d7e2SAndroid Build Coastguard Worker``` 36*cc02d7e2SAndroid Build Coastguard Worker 37*cc02d7e2SAndroid Build Coastguard WorkerTo build gRPC from source, you may need to install the following 38*cc02d7e2SAndroid Build Coastguard Workerpackages from [Homebrew](https://brew.sh): 39*cc02d7e2SAndroid Build Coastguard Worker 40*cc02d7e2SAndroid Build Coastguard Worker```sh 41*cc02d7e2SAndroid Build Coastguard Worker $ brew install autoconf automake libtool shtool 42*cc02d7e2SAndroid Build Coastguard Worker``` 43*cc02d7e2SAndroid Build Coastguard Worker 44*cc02d7e2SAndroid Build Coastguard WorkerIf you plan to build using CMake, follow the instructions from https://cmake.org/download/ 45*cc02d7e2SAndroid Build Coastguard Worker 46*cc02d7e2SAndroid Build Coastguard Worker*Tip*: when building, 47*cc02d7e2SAndroid Build Coastguard Workeryou *may* want to explicitly set the `LIBTOOL` and `LIBTOOLIZE` 48*cc02d7e2SAndroid Build Coastguard Workerenvironment variables when running `make` to ensure the version 49*cc02d7e2SAndroid Build Coastguard Workerinstalled by `brew` is being used: 50*cc02d7e2SAndroid Build Coastguard Worker 51*cc02d7e2SAndroid Build Coastguard Worker```sh 52*cc02d7e2SAndroid Build Coastguard Worker $ LIBTOOL=glibtool LIBTOOLIZE=glibtoolize make 53*cc02d7e2SAndroid Build Coastguard Worker``` 54*cc02d7e2SAndroid Build Coastguard Worker 55*cc02d7e2SAndroid Build Coastguard Worker## Windows 56*cc02d7e2SAndroid Build Coastguard Worker 57*cc02d7e2SAndroid Build Coastguard WorkerTo prepare for cmake + Microsoft Visual C++ compiler build 58*cc02d7e2SAndroid Build Coastguard Worker- Install Visual Studio 2019 or later (Visual C++ compiler will be used). 59*cc02d7e2SAndroid Build Coastguard Worker- Install [Git](https://git-scm.com/). 60*cc02d7e2SAndroid Build Coastguard Worker- Install [CMake](https://cmake.org/download/). 61*cc02d7e2SAndroid Build Coastguard Worker- Install [nasm](https://www.nasm.us/) and add it to `PATH` (`choco install nasm`) - *required by boringssl* 62*cc02d7e2SAndroid Build Coastguard Worker- (Optional) Install [Ninja](https://ninja-build.org/) (`choco install ninja`) 63*cc02d7e2SAndroid Build Coastguard Worker 64*cc02d7e2SAndroid Build Coastguard Worker# Clone the repository (including submodules) 65*cc02d7e2SAndroid Build Coastguard Worker 66*cc02d7e2SAndroid Build Coastguard WorkerBefore building, you need to clone the gRPC github repository and download submodules containing source code 67*cc02d7e2SAndroid Build Coastguard Workerfor gRPC's dependencies (that's done by the `submodule` command or `--recursive` flag). Use following commands 68*cc02d7e2SAndroid Build Coastguard Workerto clone the gRPC repository at the [latest stable release tag](https://github.com/grpc/grpc/releases) 69*cc02d7e2SAndroid Build Coastguard Worker 70*cc02d7e2SAndroid Build Coastguard Worker## Unix 71*cc02d7e2SAndroid Build Coastguard Worker 72*cc02d7e2SAndroid Build Coastguard Worker```sh 73*cc02d7e2SAndroid Build Coastguard Worker $ git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc 74*cc02d7e2SAndroid Build Coastguard Worker $ cd grpc 75*cc02d7e2SAndroid Build Coastguard Worker $ git submodule update --init 76*cc02d7e2SAndroid Build Coastguard Worker ``` 77*cc02d7e2SAndroid Build Coastguard Worker 78*cc02d7e2SAndroid Build Coastguard Worker## Windows 79*cc02d7e2SAndroid Build Coastguard Worker 80*cc02d7e2SAndroid Build Coastguard Worker``` 81*cc02d7e2SAndroid Build Coastguard Worker> git clone -b RELEASE_TAG_HERE https://github.com/grpc/grpc 82*cc02d7e2SAndroid Build Coastguard Worker> cd grpc 83*cc02d7e2SAndroid Build Coastguard Worker> git submodule update --init 84*cc02d7e2SAndroid Build Coastguard Worker``` 85*cc02d7e2SAndroid Build Coastguard Worker 86*cc02d7e2SAndroid Build Coastguard WorkerNOTE: The `bazel` build tool uses a different model for dependencies. You only need to worry about downloading submodules if you're building 87*cc02d7e2SAndroid Build Coastguard Workerwith something else than `bazel` (e.g. `cmake`). 88*cc02d7e2SAndroid Build Coastguard Worker 89*cc02d7e2SAndroid Build Coastguard Worker# Build from source 90*cc02d7e2SAndroid Build Coastguard Worker 91*cc02d7e2SAndroid Build Coastguard WorkerIn the C++ world, there's no "standard" build system that would work for all supported use cases and on all supported platforms. 92*cc02d7e2SAndroid Build Coastguard WorkerTherefore, gRPC supports several major build systems, which should satisfy most users. Depending on your needs 93*cc02d7e2SAndroid Build Coastguard Workerwe recommend building using `bazel` or `cmake`. 94*cc02d7e2SAndroid Build Coastguard Worker 95*cc02d7e2SAndroid Build Coastguard Worker## Building with bazel (recommended) 96*cc02d7e2SAndroid Build Coastguard Worker 97*cc02d7e2SAndroid Build Coastguard WorkerBazel is the primary build system for gRPC C++. If you're comfortable using bazel, we can certainly recommend it. 98*cc02d7e2SAndroid Build Coastguard WorkerUsing bazel will give you the best developer experience in addition to faster and cleaner builds. 99*cc02d7e2SAndroid Build Coastguard Worker 100*cc02d7e2SAndroid Build Coastguard WorkerYou'll need `bazel` version `1.0.0` or higher to build gRPC. 101*cc02d7e2SAndroid Build Coastguard WorkerSee [Installing Bazel](https://docs.bazel.build/versions/master/install.html) for instructions how to install bazel on your system. 102*cc02d7e2SAndroid Build Coastguard WorkerWe support building with `bazel` on Linux, MacOS and Windows. 103*cc02d7e2SAndroid Build Coastguard Worker 104*cc02d7e2SAndroid Build Coastguard WorkerFrom the grpc repository root 105*cc02d7e2SAndroid Build Coastguard Worker``` 106*cc02d7e2SAndroid Build Coastguard Worker# Build gRPC C++ 107*cc02d7e2SAndroid Build Coastguard Worker$ bazel build :all 108*cc02d7e2SAndroid Build Coastguard Worker``` 109*cc02d7e2SAndroid Build Coastguard Worker 110*cc02d7e2SAndroid Build Coastguard Worker``` 111*cc02d7e2SAndroid Build Coastguard Worker# Run all the C/C++ tests 112*cc02d7e2SAndroid Build Coastguard Worker$ bazel test --config=dbg //test/... 113*cc02d7e2SAndroid Build Coastguard Worker``` 114*cc02d7e2SAndroid Build Coastguard Worker 115*cc02d7e2SAndroid Build Coastguard WorkerNOTE: If you're using Bazel 7 or newer and working with gRPC, you'll need to turn off bzlmod. 116*cc02d7e2SAndroid Build Coastguard WorkerThis is because gRPC isn't fully compatible with bzlmod yet. To do this, add --enable_bzlmod=false to your Bazel commands. 117*cc02d7e2SAndroid Build Coastguard Worker 118*cc02d7e2SAndroid Build Coastguard WorkerNOTE: If you are a gRPC maintainer and you have access to our test cluster, you should use our [gRPC's Remote Execution environment](tools/remote_build/README.md) 119*cc02d7e2SAndroid Build Coastguard Workerto get significant improvement to the build and test speed (and a bunch of other very useful features). 120*cc02d7e2SAndroid Build Coastguard Worker 121*cc02d7e2SAndroid Build Coastguard Worker## Building with CMake 122*cc02d7e2SAndroid Build Coastguard Worker 123*cc02d7e2SAndroid Build Coastguard Worker### Linux/Unix, Using Make 124*cc02d7e2SAndroid Build Coastguard Worker 125*cc02d7e2SAndroid Build Coastguard WorkerRun from the grpc directory after cloning the repo with --recursive or updating submodules. 126*cc02d7e2SAndroid Build Coastguard Worker``` 127*cc02d7e2SAndroid Build Coastguard Worker$ mkdir -p cmake/build 128*cc02d7e2SAndroid Build Coastguard Worker$ cd cmake/build 129*cc02d7e2SAndroid Build Coastguard Worker$ cmake ../.. 130*cc02d7e2SAndroid Build Coastguard Worker$ make 131*cc02d7e2SAndroid Build Coastguard Worker``` 132*cc02d7e2SAndroid Build Coastguard Worker 133*cc02d7e2SAndroid Build Coastguard WorkerIf you want to build shared libraries (`.so` files), run `cmake` with `-DBUILD_SHARED_LIBS=ON`. 134*cc02d7e2SAndroid Build Coastguard Worker 135*cc02d7e2SAndroid Build Coastguard Worker### Windows, Using Visual Studio 2019 or later 136*cc02d7e2SAndroid Build Coastguard Worker 137*cc02d7e2SAndroid Build Coastguard WorkerWhen using the "Visual Studio" generator, 138*cc02d7e2SAndroid Build Coastguard Workercmake will generate a solution (`grpc.sln`) that contains a VS project for 139*cc02d7e2SAndroid Build Coastguard Workerevery target defined in `CMakeLists.txt` (+ a few extra convenience projects 140*cc02d7e2SAndroid Build Coastguard Workeradded automatically by cmake). After opening the solution with Visual Studio 141*cc02d7e2SAndroid Build Coastguard Workeryou will be able to browse and build the code. 142*cc02d7e2SAndroid Build Coastguard Worker``` 143*cc02d7e2SAndroid Build Coastguard Worker> @rem Run from grpc directory after cloning the repo with --recursive or updating submodules. 144*cc02d7e2SAndroid Build Coastguard Worker> md .build 145*cc02d7e2SAndroid Build Coastguard Worker> cd .build 146*cc02d7e2SAndroid Build Coastguard Worker> cmake .. -G "Visual Studio 16 2019" 147*cc02d7e2SAndroid Build Coastguard Worker> cmake --build . --config Release 148*cc02d7e2SAndroid Build Coastguard Worker``` 149*cc02d7e2SAndroid Build Coastguard Worker 150*cc02d7e2SAndroid Build Coastguard WorkerUsing gRPC C++ as a DLL is not recommended, but you can still enable it by running `cmake` with `-DBUILD_SHARED_LIBS=ON`. 151*cc02d7e2SAndroid Build Coastguard Worker 152*cc02d7e2SAndroid Build Coastguard Worker### Windows, Using Ninja (faster build). 153*cc02d7e2SAndroid Build Coastguard Worker 154*cc02d7e2SAndroid Build Coastguard WorkerPlease note that when using Ninja, you will still need Visual C++ (part of Visual Studio) 155*cc02d7e2SAndroid Build Coastguard Workerinstalled to be able to compile the C/C++ sources. 156*cc02d7e2SAndroid Build Coastguard Worker``` 157*cc02d7e2SAndroid Build Coastguard Worker> @rem Run from grpc directory after cloning the repo with --recursive or updating submodules. 158*cc02d7e2SAndroid Build Coastguard Worker> cd cmake 159*cc02d7e2SAndroid Build Coastguard Worker> md build 160*cc02d7e2SAndroid Build Coastguard Worker> cd build 161*cc02d7e2SAndroid Build Coastguard Worker> call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x64 162*cc02d7e2SAndroid Build Coastguard Worker> cmake ..\.. -GNinja -DCMAKE_BUILD_TYPE=Release 163*cc02d7e2SAndroid Build Coastguard Worker> cmake --build . 164*cc02d7e2SAndroid Build Coastguard Worker``` 165*cc02d7e2SAndroid Build Coastguard Worker 166*cc02d7e2SAndroid Build Coastguard WorkerUsing gRPC C++ as a DLL is not recommended, but you can still enable it by running `cmake` with `-DBUILD_SHARED_LIBS=ON`. 167*cc02d7e2SAndroid Build Coastguard Worker 168*cc02d7e2SAndroid Build Coastguard Worker### Windows: A note on building shared libs (DLLs) 169*cc02d7e2SAndroid Build Coastguard Worker 170*cc02d7e2SAndroid Build Coastguard WorkerWindows DLL build is supported at a "best effort" basis and we don't recommend using gRPC C++ as a DLL as there are some known drawbacks around how C++ DLLs work on Windows. For example, there is no stable C++ ABI and you can't safely allocate memory in one DLL, and free it in another etc. 171*cc02d7e2SAndroid Build Coastguard Worker 172*cc02d7e2SAndroid Build Coastguard WorkerThat said, we don't actively prohibit building DLLs on windows (it can be enabled in cmake with `-DBUILD_SHARED_LIBS=ON`), and are free to use the DLL builds 173*cc02d7e2SAndroid Build Coastguard Workerat your own risk. 174*cc02d7e2SAndroid Build Coastguard Worker- you've been warned that there are some important drawbacks and some things might not work at all or will be broken in interesting ways. 175*cc02d7e2SAndroid Build Coastguard Worker- we don't have extensive testing for DLL builds in place (to avoid maintenance costs, increased test duration etc.) so regressions / build breakages might occur 176*cc02d7e2SAndroid Build Coastguard Worker 177*cc02d7e2SAndroid Build Coastguard Worker### Dependency management 178*cc02d7e2SAndroid Build Coastguard Worker 179*cc02d7e2SAndroid Build Coastguard WorkergRPC's CMake build system has two options for handling dependencies. 180*cc02d7e2SAndroid Build Coastguard WorkerCMake can build the dependencies for you, or it can search for libraries 181*cc02d7e2SAndroid Build Coastguard Workerthat are already installed on your system and use them to build gRPC. 182*cc02d7e2SAndroid Build Coastguard Worker 183*cc02d7e2SAndroid Build Coastguard WorkerThis behavior is controlled by the `gRPC_<depname>_PROVIDER` CMake variables, 184*cc02d7e2SAndroid Build Coastguard Workere.g. `gRPC_CARES_PROVIDER`. The options that these variables take are as follows: 185*cc02d7e2SAndroid Build Coastguard Worker 186*cc02d7e2SAndroid Build Coastguard Worker* module - build dependencies alongside gRPC. The source code is obtained from 187*cc02d7e2SAndroid Build Coastguard WorkergRPC's git submodules. 188*cc02d7e2SAndroid Build Coastguard Worker* package - use external copies of dependencies that are already available 189*cc02d7e2SAndroid Build Coastguard Workeron your system. These could come from your system package manager, or perhaps 190*cc02d7e2SAndroid Build Coastguard Workeryou pre-installed them using CMake with the `CMAKE_INSTALL_PREFIX` option. 191*cc02d7e2SAndroid Build Coastguard Worker 192*cc02d7e2SAndroid Build Coastguard WorkerFor example, if you set `gRPC_CARES_PROVIDER=module`, then CMake will build 193*cc02d7e2SAndroid Build Coastguard Workerc-ares before building gRPC. On the other hand, if you set 194*cc02d7e2SAndroid Build Coastguard Worker`gRPC_CARES_PROVIDER=package`, then CMake will search for a copy of c-ares 195*cc02d7e2SAndroid Build Coastguard Workerthat's already installed on your system and use it to build gRPC. 196*cc02d7e2SAndroid Build Coastguard Worker 197*cc02d7e2SAndroid Build Coastguard Worker### Install after build 198*cc02d7e2SAndroid Build Coastguard Worker 199*cc02d7e2SAndroid Build Coastguard WorkerPerform the following steps to install gRPC using CMake. 200*cc02d7e2SAndroid Build Coastguard Worker* Set `-DgRPC_INSTALL=ON` 201*cc02d7e2SAndroid Build Coastguard Worker* Build the `install` target 202*cc02d7e2SAndroid Build Coastguard Worker 203*cc02d7e2SAndroid Build Coastguard WorkerThe install destination is controlled by the 204*cc02d7e2SAndroid Build Coastguard Worker[`CMAKE_INSTALL_PREFIX`](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html) variable. 205*cc02d7e2SAndroid Build Coastguard Worker 206*cc02d7e2SAndroid Build Coastguard WorkerIf you are running CMake v3.13 or newer you can build gRPC's dependencies 207*cc02d7e2SAndroid Build Coastguard Workerin "module" mode and install them alongside gRPC in a single step. 208*cc02d7e2SAndroid Build Coastguard Worker[Example](test/distrib/cpp/run_distrib_test_cmake_module_install.sh) 209*cc02d7e2SAndroid Build Coastguard Worker 210*cc02d7e2SAndroid Build Coastguard WorkerIf you are building gRPC < 1.27 or if you are using CMake < 3.13 you will need 211*cc02d7e2SAndroid Build Coastguard Workerto select "package" mode (rather than "module" mode) for the dependencies. 212*cc02d7e2SAndroid Build Coastguard WorkerThis means you will need to have external copies of these libraries available 213*cc02d7e2SAndroid Build Coastguard Workeron your system. This [example](test/distrib/cpp/run_distrib_test_cmake.sh) shows 214*cc02d7e2SAndroid Build Coastguard Workerhow to install dependencies with cmake before proceeding to installing gRPC itself. 215*cc02d7e2SAndroid Build Coastguard Worker 216*cc02d7e2SAndroid Build Coastguard Worker``` 217*cc02d7e2SAndroid Build Coastguard Worker# NOTE: all of gRPC's dependencies need to be already installed 218*cc02d7e2SAndroid Build Coastguard Worker$ cmake ../.. -DgRPC_INSTALL=ON \ 219*cc02d7e2SAndroid Build Coastguard Worker -DCMAKE_BUILD_TYPE=Release \ 220*cc02d7e2SAndroid Build Coastguard Worker -DgRPC_ABSL_PROVIDER=package \ 221*cc02d7e2SAndroid Build Coastguard Worker -DgRPC_CARES_PROVIDER=package \ 222*cc02d7e2SAndroid Build Coastguard Worker -DgRPC_PROTOBUF_PROVIDER=package \ 223*cc02d7e2SAndroid Build Coastguard Worker -DgRPC_RE2_PROVIDER=package \ 224*cc02d7e2SAndroid Build Coastguard Worker -DgRPC_SSL_PROVIDER=package \ 225*cc02d7e2SAndroid Build Coastguard Worker -DgRPC_ZLIB_PROVIDER=package 226*cc02d7e2SAndroid Build Coastguard Worker$ make 227*cc02d7e2SAndroid Build Coastguard Worker$ make install 228*cc02d7e2SAndroid Build Coastguard Worker``` 229*cc02d7e2SAndroid Build Coastguard Worker 230*cc02d7e2SAndroid Build Coastguard Worker### Cross-compiling 231*cc02d7e2SAndroid Build Coastguard Worker 232*cc02d7e2SAndroid Build Coastguard WorkerYou can use CMake to cross-compile gRPC for another architecture. In order to 233*cc02d7e2SAndroid Build Coastguard Workerdo so, you will first need to build `protoc` and `grpc_cpp_plugin` 234*cc02d7e2SAndroid Build Coastguard Workerfor the host architecture. These tools are used during the build of gRPC, so 235*cc02d7e2SAndroid Build Coastguard Workerwe need copies of executables that can be run natively. 236*cc02d7e2SAndroid Build Coastguard Worker 237*cc02d7e2SAndroid Build Coastguard WorkerYou will likely need to install the toolchain for the platform you are 238*cc02d7e2SAndroid Build Coastguard Workertargeting for your cross-compile. Once you have done so, you can write a 239*cc02d7e2SAndroid Build Coastguard Workertoolchain file to tell CMake where to find the compilers and system tools 240*cc02d7e2SAndroid Build Coastguard Workerthat will be used for this build. 241*cc02d7e2SAndroid Build Coastguard Worker 242*cc02d7e2SAndroid Build Coastguard WorkerThis toolchain file is specified to CMake by setting the `CMAKE_TOOLCHAIN_FILE` 243*cc02d7e2SAndroid Build Coastguard Workervariable. 244*cc02d7e2SAndroid Build Coastguard Worker``` 245*cc02d7e2SAndroid Build Coastguard Worker$ cmake ../.. -DCMAKE_TOOLCHAIN_FILE=path/to/file 246*cc02d7e2SAndroid Build Coastguard Worker$ make 247*cc02d7e2SAndroid Build Coastguard Worker``` 248*cc02d7e2SAndroid Build Coastguard Worker 249*cc02d7e2SAndroid Build Coastguard Worker[Cross-compile example](test/distrib/cpp/run_distrib_test_cmake_aarch64_cross.sh) 250*cc02d7e2SAndroid Build Coastguard Worker 251*cc02d7e2SAndroid Build Coastguard Worker### A note on SONAME and its ABI compatibility implications in the cmake build 252*cc02d7e2SAndroid Build Coastguard Worker 253*cc02d7e2SAndroid Build Coastguard WorkerBest efforts are made to bump the SONAME revision during ABI breaches. While a 254*cc02d7e2SAndroid Build Coastguard Workerchange in the SONAME clearly indicates an ABI incompatibility, no hard guarantees 255*cc02d7e2SAndroid Build Coastguard Workercan be made about any sort of ABI stability across the same SONAME version. 256*cc02d7e2SAndroid Build Coastguard Worker 257*cc02d7e2SAndroid Build Coastguard Worker## Building with make on UNIX systems (deprecated) 258*cc02d7e2SAndroid Build Coastguard Worker 259*cc02d7e2SAndroid Build Coastguard WorkerNOTE: `make` used to be gRPC's default build system, but we're no longer recommending it. You should use `bazel` or `cmake` instead. The `Makefile` is only intended for internal usage and is not meant for public consumption. 260*cc02d7e2SAndroid Build Coastguard Worker 261*cc02d7e2SAndroid Build Coastguard WorkerFrom the grpc repository root 262*cc02d7e2SAndroid Build Coastguard Worker```sh 263*cc02d7e2SAndroid Build Coastguard Worker $ make 264*cc02d7e2SAndroid Build Coastguard Worker``` 265*cc02d7e2SAndroid Build Coastguard Worker 266*cc02d7e2SAndroid Build Coastguard WorkerNOTE: if you get an error on linux such as 'aclocal-1.15: command not found', which can happen if you ran 'make' before installing the pre-reqs, try the following: 267*cc02d7e2SAndroid Build Coastguard Worker```sh 268*cc02d7e2SAndroid Build Coastguard Worker$ git clean -f -d -x && git submodule foreach --recursive git clean -f -d -x 269*cc02d7e2SAndroid Build Coastguard Worker$ [sudo] apt-get install build-essential autoconf libtool pkg-config 270*cc02d7e2SAndroid Build Coastguard Worker$ make 271*cc02d7e2SAndroid Build Coastguard Worker``` 272*cc02d7e2SAndroid Build Coastguard Worker 273*cc02d7e2SAndroid Build Coastguard Worker### A note on `protoc` 274*cc02d7e2SAndroid Build Coastguard Worker 275*cc02d7e2SAndroid Build Coastguard WorkerBy default gRPC uses [protocol buffers](https://github.com/protocolbuffers/protobuf), 276*cc02d7e2SAndroid Build Coastguard Workeryou will need the `protoc` compiler to generate stub server and client code. 277*cc02d7e2SAndroid Build Coastguard Worker 278*cc02d7e2SAndroid Build Coastguard WorkerIf you compile gRPC from source, as described above, the Makefile will 279*cc02d7e2SAndroid Build Coastguard Workerautomatically try compiling the `protoc` in third_party if you cloned the 280*cc02d7e2SAndroid Build Coastguard Workerrepository recursively and it detects that you do not already have 'protoc' compiler 281*cc02d7e2SAndroid Build Coastguard Workerinstalled. 282