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 | |
Dan Ciruli | de3c654 | 2015-02-25 12:50:09 -0800 | [diff] [blame] | 12 | $ git clone https://github.com/grpc/grpc.git |
| 13 | $ git submodule update --init |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 14 | |
Abhishek Kumar | 2deb986 | 2015-02-25 16:55:58 -0800 | [diff] [blame] | 15 | $ cd grpc |
Abhishek Kumar | 8770936 | 2015-02-25 16:54:44 -0800 | [diff] [blame] | 16 | |
| 17 | $ make |
| 18 | $ sudo make install |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 19 | |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 20 | You don't need anything else than GNU Make, gcc and autotools. Under a Debian |
| 21 | or Ubuntu system, this should boil down to the following packages: |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 22 | |
Dan Ciruli | de3c654 | 2015-02-25 12:50:09 -0800 | [diff] [blame] | 23 | $ apt-get install build-essential autoconf libtool |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 24 | |
| 25 | Building the python wrapper requires the following: |
| 26 | |
| 27 | # apt-get install python-all-dev python-virtualenv |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 28 | |
Nicolas "Pixel" Noble | 522d712 | 2015-02-19 01:28:02 +0100 | [diff] [blame] | 29 | If you want to install in a different directory than the default /usr/lib, you can |
| 30 | override it on the command line: |
| 31 | |
| 32 | # make install prefix=/opt |
| 33 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 34 | |
| 35 | ******************************* |
| 36 | * More detailled instructions * |
| 37 | ******************************* |
| 38 | |
| 39 | Setting up dependencies |
| 40 | ======================= |
| 41 | |
| 42 | Dependencies to compile the libraries |
| 43 | ------------------------------------- |
| 44 | |
| 45 | grpc libraries have few external dependencies. If you need to compile and |
| 46 | install them, they are present in the third_party directory if you have |
| 47 | cloned the github repository recursively. If you didn't clone recursively, |
| 48 | you can still get them later by running the following command: |
| 49 | |
| 50 | $ git submodule update --init |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 51 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 52 | 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] | 53 | if you were to clone recursively our git repository: it will automatically |
| 54 | compile zlib and OpenSSL, which are core requirements for grpc. Note this |
| 55 | creates grpc libraries that will have zlib and OpenSSL built-in inside of them, |
| 56 | which significantly increases the libraries' size. |
| 57 | |
| 58 | In order to decrease that size, you can manually install zlib and OpenSSL on |
| 59 | your system, so that the Makefile can use them instead. |
| 60 | |
| 61 | Under a Debian or Ubuntu system, one can acquire the development package |
| 62 | for zlib this way: |
| 63 | |
| 64 | # apt-get install zlib1g-dev |
| 65 | |
| 66 | To the best of our knowledge, no distribution has an OpenSSL package that |
| 67 | supports ALPN yet, so you would still have to depend on installing from source |
| 68 | for that particular dependency if you want to reduce the libraries' size. |
| 69 | |
| 70 | The recommended version of OpenSSL that provides ALPN support is available |
| 71 | at this URL: |
| 72 | |
Nicolas "Pixel" Noble | d566021 | 2015-01-23 20:35:49 +0100 | [diff] [blame] | 73 | https://www.openssl.org/source/openssl-1.0.2.tar.gz |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 74 | |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 75 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 76 | Dependencies to compile and run the tests |
| 77 | ----------------------------------------- |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 78 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 79 | Compiling and running grpc plain-C tests dont't require any more dependency. |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 80 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 81 | |
| 82 | 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] | 83 | gflags. Although gflags is provided in third_party, you will need to manually |
| 84 | install that dependency on your system to run these tests. |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 85 | |
| 86 | Under a Debian or Ubuntu system, you can install the gtests and gflags packages |
| 87 | using apt-get: |
| 88 | |
| 89 | # apt-get install libgflags-dev libgtest-dev |
| 90 | |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 91 | However, protobuf 3.0.0 isn't in a debian package yet, but the Makefile will |
| 92 | automatically try and compile the one present in third_party if you cloned the |
| 93 | repository recursively, and that it detects your system is lacking it. |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 94 | |
| 95 | 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] | 96 | itself, notably the autoconf suite. If you have apt-get, you can install |
| 97 | these dependencies this way: |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 98 | |
Nicolas Noble | c70752a | 2015-02-12 17:01:52 -0800 | [diff] [blame] | 99 | # apt-get install autoconf libtool |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 100 | |
Nicolas "Pixel" Noble | d66cba2 | 2015-02-14 02:59:12 +0100 | [diff] [blame] | 101 | If you want to run the tests using one of the sanitized configurations, you |
| 102 | will need clang and its instrumented libc++: |
| 103 | |
| 104 | # apt-get install clang libc++-dev |
| 105 | |
vjpai | 7cc2c30 | 2015-02-18 12:33:37 -0800 | [diff] [blame] | 106 | Mac-specific notes: |
| 107 | ------------------- |
| 108 | |
| 109 | For a Mac system, git is not available by default. You will first need to |
| 110 | install Xcode from the Mac AppStore and then run the following command from a |
| 111 | terminal: |
| 112 | |
| 113 | $ sudo xcode-select --install |
| 114 | |
| 115 | You should also install "port" following the instructions at |
| 116 | https://www.macports.org . This will reside in /opt/local/bin/port for |
| 117 | most Mac installations. Do the "git submodule" command listed above. |
| 118 | |
| 119 | Then execute the following for all the needed build dependencies |
| 120 | |
| 121 | $ sudo /opt/local/bin/port install autoconf automake libtool gflags cmake |
| 122 | $ mkdir ~/gtest |
| 123 | $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn |
| 124 | $ mkdir mybuild |
| 125 | $ cd mybuild |
| 126 | $ cmake ../gtest-svn |
| 127 | $ make |
| 128 | $ make gtest.a gtest_main.a |
| 129 | $ sudo cp libgtest.a libgtest_main.a /opt/local/lib |
| 130 | $ sudo mkdir /opt/local/include/gtest |
| 131 | $ sudo cp -pr ../gtest-svn/include/gtest /opt/local/include/gtest |
| 132 | |
| 133 | We will also need to make openssl and install it appropriately |
| 134 | |
| 135 | $ cd <git directory> |
| 136 | $ cd third_party/openssl |
| 137 | $ sudo make install |
| 138 | $ cd ../../ |
| 139 | |
| 140 | If you are going to make changes and need to regenerate the projects file, |
| 141 | you will need to install certain modules for python. |
| 142 | |
| 143 | $ sudo easy_install simplejson mako |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 144 | |
| 145 | A word on OpenSSL |
| 146 | ----------------- |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 147 | |
Abhishek Kumar | 3dd9df9 | 2015-02-10 10:16:41 -0800 | [diff] [blame] | 148 | Secure HTTP2 requires the TLS extension ALPN (see rfc 7301 and |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 149 | 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] | 150 | 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] | 151 | of OpenSSL that has ALPN support, and this explains our dependency on it. |
| 152 | |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 153 | Note that the Makefile supports compiling only the unsecure elements of grpc, |
| 154 | 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] | 155 | with installing only the elements you require. However, we strongly recommend |
Abhishek Kumar | 3dd9df9 | 2015-02-10 10:16:41 -0800 | [diff] [blame] | 156 | the use of encryption for all network traffic, and discourage the use of grpc |
| 157 | without TLS. |
nnoble | 69ac39f | 2014-12-12 15:43:38 -0800 | [diff] [blame] | 158 | |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 159 | |
| 160 | Compiling |
| 161 | ========= |
| 162 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 163 | If you have all the dependencies mentioned above, you should simply be able |
| 164 | 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] | 165 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 166 | $ make |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 167 | |
| 168 | |
| 169 | Testing |
| 170 | ======= |
| 171 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 172 | To build and run the tests, you can run the command: |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 173 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 174 | $ make test |
| 175 | |
| 176 | If you want to be able to run them in parallel, and get better output, you can |
| 177 | also use the python tool we have written: |
| 178 | |
| 179 | $ ./tools/run_tests/run_tests.py |
nnoble | 0005b77 | 2014-12-10 16:25:34 -0800 | [diff] [blame] | 180 | |
| 181 | |
| 182 | Installing |
| 183 | ========== |
| 184 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 185 | 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] | 186 | libraries and headers: |
| 187 | |
Nicolas Noble | 6ae8ef1 | 2015-01-16 15:03:42 -0800 | [diff] [blame] | 188 | # make install |