Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 1 | These instructions only cover building grpc C and C++ libraries under |
| 2 | typical unix systems. If you need more information, please try grpc's |
| 3 | wiki pages: |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 4 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 5 | https://github.com/google/grpc/wiki |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 6 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 7 | |
| 8 | ************************* |
| 9 | * If you are in a hurry * |
| 10 | ************************* |
| 11 | |
Stanley Cheung | a79a896 | 2015-08-19 10:43:28 -0700 | [diff] [blame] | 12 | On Linux (Debian): |
| 13 | |
Stanley Cheung | 581846b | 2015-09-04 12:04:17 -0700 | [diff] [blame] | 14 | Note: you will need to add the Debian 'jessie-backports' distribution to your sources |
Stanley Cheung | a79a896 | 2015-08-19 10:43:28 -0700 | [diff] [blame] | 15 | file first. |
| 16 | |
| 17 | Add the following line to your `/etc/apt/sources.list` file: |
| 18 | |
Stanley Cheung | 581846b | 2015-09-04 12:04:17 -0700 | [diff] [blame] | 19 | deb http://http.debian.net/debian jessie-backports main |
Stanley Cheung | a79a896 | 2015-08-19 10:43:28 -0700 | [diff] [blame] | 20 | |
Stanley Cheung | 5329e4b | 2015-08-19 15:59:59 -0700 | [diff] [blame] | 21 | Install the gRPC library: |
| 22 | |
| 23 | $ [sudo] apt-get install libgrpc-dev |
Stanley Cheung | a79a896 | 2015-08-19 10:43:28 -0700 | [diff] [blame] | 24 | |
| 25 | OR |
| 26 | |
Dan Ciruli | de3c654 | 2015-02-25 12:50:09 -0800 | [diff] [blame] | 27 | $ git clone https://github.com/grpc/grpc.git |
Dan Ciruli | 4175d84 | 2015-02-25 16:24:22 -0800 | [diff] [blame] | 28 | $ cd grpc |
Dan Ciruli | de3c654 | 2015-02-25 12:50:09 -0800 | [diff] [blame] | 29 | $ git submodule update --init |
Dan Ciruli | 4175d84 | 2015-02-25 16:24:22 -0800 | [diff] [blame] | 30 | $ make |
Stanley Cheung | 5329e4b | 2015-08-19 15:59:59 -0700 | [diff] [blame] | 31 | $ [sudo] make install |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 32 | |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 33 | You don't need anything else than GNU Make, gcc and autotools. Under a Debian |
| 34 | or Ubuntu system, this should boil down to the following packages: |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 35 | |
Stanley Cheung | 5329e4b | 2015-08-19 15:59:59 -0700 | [diff] [blame] | 36 | $ [sudo] apt-get install build-essential autoconf libtool |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 37 | |
| 38 | Building the python wrapper requires the following: |
| 39 | |
Stanley Cheung | 5329e4b | 2015-08-19 15:59:59 -0700 | [diff] [blame] | 40 | $ [sudo] apt-get install python-all-dev python-virtualenv |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 41 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 42 | If you want to install in a different directory than the default /usr/lib, you can |
| 43 | override it on the command line: |
| 44 | |
Stanley Cheung | 5329e4b | 2015-08-19 15:59:59 -0700 | [diff] [blame] | 45 | $ [sudo] make install prefix=/opt |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 46 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 47 | |
| 48 | ******************************* |
| 49 | * More detailled instructions * |
| 50 | ******************************* |
| 51 | |
| 52 | Setting up dependencies |
| 53 | ======================= |
| 54 | |
| 55 | Dependencies to compile the libraries |
| 56 | ------------------------------------- |
| 57 | |
| 58 | grpc libraries have few external dependencies. If you need to compile and |
| 59 | install them, they are present in the third_party directory if you have |
| 60 | cloned the github repository recursively. If you didn't clone recursively, |
| 61 | you can still get them later by running the following command: |
| 62 | |
| 63 | $ git submodule update --init |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 64 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 65 | Note that the Makefile makes it much easier for you to compile from sources |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 66 | if you were to clone recursively our git repository: it will automatically |
| 67 | compile zlib and OpenSSL, which are core requirements for grpc. Note this |
| 68 | creates grpc libraries that will have zlib and OpenSSL built-in inside of them, |
| 69 | which significantly increases the libraries' size. |
| 70 | |
| 71 | In order to decrease that size, you can manually install zlib and OpenSSL on |
| 72 | your system, so that the Makefile can use them instead. |
| 73 | |
| 74 | Under a Debian or Ubuntu system, one can acquire the development package |
| 75 | for zlib this way: |
| 76 | |
| 77 | # apt-get install zlib1g-dev |
| 78 | |
| 79 | To the best of our knowledge, no distribution has an OpenSSL package that |
| 80 | supports ALPN yet, so you would still have to depend on installing from source |
| 81 | for that particular dependency if you want to reduce the libraries' size. |
| 82 | |
| 83 | The recommended version of OpenSSL that provides ALPN support is available |
| 84 | at this URL: |
| 85 | |
Nicolas "Pixel" Noble | d566021 | 2015-01-23 20:35:49 +0100 | [diff] [blame] | 86 | https://www.openssl.org/source/openssl-1.0.2.tar.gz |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 87 | |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 88 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 89 | Dependencies to compile and run the tests |
| 90 | ----------------------------------------- |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 91 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 92 | Compiling and running grpc plain-C tests dont't require any more dependency. |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 93 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 94 | |
| 95 | Compiling and running grpc C++ tests depend on protobuf 3.0.0, gtest and |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 96 | gflags. Although gflags is provided in third_party, you will need to manually |
| 97 | install that dependency on your system to run these tests. |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 98 | |
| 99 | Under a Debian or Ubuntu system, you can install the gtests and gflags packages |
| 100 | using apt-get: |
| 101 | |
| 102 | # apt-get install libgflags-dev libgtest-dev |
| 103 | |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 104 | However, protobuf 3.0.0 isn't in a debian package yet, but the Makefile will |
| 105 | automatically try and compile the one present in third_party if you cloned the |
| 106 | repository recursively, and that it detects your system is lacking it. |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 107 | |
| 108 | Compiling and installing protobuf 3.0.0 requires a few more dependencies in |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 109 | itself, notably the autoconf suite. If you have apt-get, you can install |
| 110 | these dependencies this way: |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 111 | |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 112 | # apt-get install autoconf libtool |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 113 | |
Nicolas "Pixel" Noble | d66cba2 | 2015-02-14 02:59:12 +0100 | [diff] [blame] | 114 | If you want to run the tests using one of the sanitized configurations, you |
| 115 | will need clang and its instrumented libc++: |
| 116 | |
| 117 | # apt-get install clang libc++-dev |
| 118 | |
vjpai | 7cc2c30 | 2015-02-18 12:33:37 -0800 | [diff] [blame] | 119 | Mac-specific notes: |
| 120 | ------------------- |
| 121 | |
| 122 | For a Mac system, git is not available by default. You will first need to |
| 123 | install Xcode from the Mac AppStore and then run the following command from a |
| 124 | terminal: |
| 125 | |
| 126 | $ sudo xcode-select --install |
| 127 | |
| 128 | You should also install "port" following the instructions at |
| 129 | https://www.macports.org . This will reside in /opt/local/bin/port for |
| 130 | most Mac installations. Do the "git submodule" command listed above. |
| 131 | |
| 132 | Then execute the following for all the needed build dependencies |
| 133 | |
| 134 | $ sudo /opt/local/bin/port install autoconf automake libtool gflags cmake |
Jorge Canizales | 123e5d8 | 2015-07-22 21:11:41 -0700 | [diff] [blame] | 135 | $ mkdir ~/gtest-svn |
vjpai | 7cc2c30 | 2015-02-18 12:33:37 -0800 | [diff] [blame] | 136 | $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn |
| 137 | $ mkdir mybuild |
| 138 | $ cd mybuild |
| 139 | $ cmake ../gtest-svn |
| 140 | $ make |
| 141 | $ make gtest.a gtest_main.a |
| 142 | $ sudo cp libgtest.a libgtest_main.a /opt/local/lib |
| 143 | $ sudo mkdir /opt/local/include/gtest |
| 144 | $ sudo cp -pr ../gtest-svn/include/gtest /opt/local/include/gtest |
| 145 | |
| 146 | We will also need to make openssl and install it appropriately |
| 147 | |
| 148 | $ cd <git directory> |
| 149 | $ cd third_party/openssl |
vjpai | 37b9ec1 | 2015-08-10 10:02:09 -0700 | [diff] [blame] | 150 | $ ./config |
vjpai | 7cc2c30 | 2015-02-18 12:33:37 -0800 | [diff] [blame] | 151 | $ sudo make install |
| 152 | $ cd ../../ |
| 153 | |
| 154 | If you are going to make changes and need to regenerate the projects file, |
| 155 | you will need to install certain modules for python. |
| 156 | |
| 157 | $ sudo easy_install simplejson mako |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 158 | |
Nicolas "Pixel" Noble | 5fc1adf | 2015-05-10 22:20:31 +0200 | [diff] [blame] | 159 | Mingw-specific notes: |
| 160 | --------------------- |
| 161 | |
| 162 | While gRPC compiles properly under mingw, some more preparation work is needed. |
| 163 | The recommendation is to use msys2. The installation instructions are available |
| 164 | at that address: http://msys2.github.io/ |
| 165 | |
| 166 | Once this is installed, make sure you are using the following: MinGW-w64 Win64. |
| 167 | You'll be required to install a few more packages: |
| 168 | |
| 169 | $ pacman -S make mingw-w64-x86_64-gcc mingw-w64-x86_64-zlib autoconf automake libtool |
| 170 | |
| 171 | Please also install OpenSSL from that website: |
| 172 | |
| 173 | http://slproweb.com/products/Win32OpenSSL.html |
| 174 | |
| 175 | The package Win64 OpenSSL v1.0.2a should do. At that point you should be able |
| 176 | to compile gRPC with the following: |
| 177 | |
| 178 | $ export LDFLAGS="-L/mingw64/lib -L/c/OpenSSL-Win64" |
| 179 | $ export CPPFLAGS="-I/mingw64/include -I/c/OpenSSL-Win64/include" |
| 180 | $ make |
| 181 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 182 | A word on OpenSSL |
| 183 | ----------------- |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 184 | |
Abhishek Kumar | 3dd9df9 | 2015-02-10 10:16:41 -0800 | [diff] [blame] | 185 | Secure HTTP2 requires the TLS extension ALPN (see rfc 7301 and |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 186 | http://http2.github.io/http2-spec/ section 3.3). Our HTTP2 implementation |
Nicolas "Pixel" Noble | d566021 | 2015-01-23 20:35:49 +0100 | [diff] [blame] | 187 | relies on OpenSSL's implementation. OpenSSL 1.0.2 is the first released version |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 188 | of OpenSSL that has ALPN support, and this explains our dependency on it. |
| 189 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 190 | Note that the Makefile supports compiling only the unsecure elements of grpc, |
| 191 | and if you do not have OpenSSL and do not want it, you can still proceed |
Abhishek Kumar | 6749e73 | 2015-02-10 10:59:52 -0800 | [diff] [blame] | 192 | with installing only the elements you require. However, we strongly recommend |
Abhishek Kumar | 3dd9df9 | 2015-02-10 10:16:41 -0800 | [diff] [blame] | 193 | the use of encryption for all network traffic, and discourage the use of grpc |
| 194 | without TLS. |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 195 | |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 196 | |
| 197 | Compiling |
| 198 | ========= |
| 199 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 200 | If you have all the dependencies mentioned above, you should simply be able |
| 201 | to go ahead and run "make" to compile grpc's C and C++ libraries: |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 202 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 203 | $ make |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 204 | |
| 205 | |
| 206 | Testing |
| 207 | ======= |
| 208 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 209 | To build and run the tests, you can run the command: |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 210 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 211 | $ make test |
| 212 | |
| 213 | If you want to be able to run them in parallel, and get better output, you can |
| 214 | also use the python tool we have written: |
| 215 | |
| 216 | $ ./tools/run_tests/run_tests.py |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 217 | |
| 218 | |
| 219 | Installing |
| 220 | ========== |
| 221 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 222 | Once everything is compiled, you should be able to install grpc C and C++ |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 223 | libraries and headers: |
| 224 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 225 | # make install |