blob: 2f5f29c788fe9f03aead9f973da1080e954a90a3 [file] [log] [blame]
Nicolas Noble6ae8ef12015-01-16 15:03:42 -08001These instructions only cover building grpc C and C++ libraries under
2typical unix systems. If you need more information, please try grpc's
3wiki pages:
nnoble0005b772014-12-10 16:25:34 -08004
Nicolas Noble6ae8ef12015-01-16 15:03:42 -08005 https://github.com/google/grpc/wiki
nnoble0005b772014-12-10 16:25:34 -08006
Nicolas Noble6ae8ef12015-01-16 15:03:42 -08007
8*************************
9* If you are in a hurry *
10*************************
11
12A typical unix installation won't require any more steps than running:
13
14 $ make
15 # make install
16
Nicolas Noblec70752a2015-02-12 17:01:52 -080017You don't need anything else than GNU Make, gcc and autotools. Under a Debian
18or Ubuntu system, this should boil down to the following packages:
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080019
Nicolas Noblec70752a2015-02-12 17:01:52 -080020 # apt-get install build-essential autoconf libtool
21
22Building the python wrapper requires the following:
23
24 # apt-get install python-all-dev python-virtualenv
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080025
Nicolas "Pixel" Noble522d7122015-02-19 01:28:02 +010026If you want to install in a different directory than the default /usr/lib, you can
27override it on the command line:
28
29 # make install prefix=/opt
30
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080031
32*******************************
33* More detailled instructions *
34*******************************
35
36Setting up dependencies
37=======================
38
39Dependencies to compile the libraries
40-------------------------------------
41
42grpc libraries have few external dependencies. If you need to compile and
43install them, they are present in the third_party directory if you have
44cloned the github repository recursively. If you didn't clone recursively,
45you can still get them later by running the following command:
46
47 $ git submodule update --init
nnoble0005b772014-12-10 16:25:34 -080048
nnoble69ac39f2014-12-12 15:43:38 -080049Note that the Makefile makes it much easier for you to compile from sources
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080050if you were to clone recursively our git repository: it will automatically
51compile zlib and OpenSSL, which are core requirements for grpc. Note this
52creates grpc libraries that will have zlib and OpenSSL built-in inside of them,
53which significantly increases the libraries' size.
54
55In order to decrease that size, you can manually install zlib and OpenSSL on
56your system, so that the Makefile can use them instead.
57
58Under a Debian or Ubuntu system, one can acquire the development package
59for zlib this way:
60
61 # apt-get install zlib1g-dev
62
63To the best of our knowledge, no distribution has an OpenSSL package that
64supports ALPN yet, so you would still have to depend on installing from source
65for that particular dependency if you want to reduce the libraries' size.
66
67The recommended version of OpenSSL that provides ALPN support is available
68at this URL:
69
Nicolas "Pixel" Nobled5660212015-01-23 20:35:49 +010070 https://www.openssl.org/source/openssl-1.0.2.tar.gz
nnoble69ac39f2014-12-12 15:43:38 -080071
nnoble0005b772014-12-10 16:25:34 -080072
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080073Dependencies to compile and run the tests
74-----------------------------------------
nnoble0005b772014-12-10 16:25:34 -080075
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080076Compiling and running grpc plain-C tests dont't require any more dependency.
nnoble0005b772014-12-10 16:25:34 -080077
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080078
79Compiling and running grpc C++ tests depend on protobuf 3.0.0, gtest and
Nicolas Noblec70752a2015-02-12 17:01:52 -080080gflags. Although gflags is provided in third_party, you will need to manually
81install that dependency on your system to run these tests.
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080082
83Under a Debian or Ubuntu system, you can install the gtests and gflags packages
84using apt-get:
85
86 # apt-get install libgflags-dev libgtest-dev
87
Nicolas Noblec70752a2015-02-12 17:01:52 -080088However, protobuf 3.0.0 isn't in a debian package yet, but the Makefile will
89automatically try and compile the one present in third_party if you cloned the
90repository recursively, and that it detects your system is lacking it.
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080091
92Compiling and installing protobuf 3.0.0 requires a few more dependencies in
Nicolas Noblec70752a2015-02-12 17:01:52 -080093itself, notably the autoconf suite. If you have apt-get, you can install
94these dependencies this way:
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080095
Nicolas Noblec70752a2015-02-12 17:01:52 -080096 # apt-get install autoconf libtool
Nicolas Noble6ae8ef12015-01-16 15:03:42 -080097
Nicolas "Pixel" Nobled66cba22015-02-14 02:59:12 +010098If you want to run the tests using one of the sanitized configurations, you
99will need clang and its instrumented libc++:
100
101 # apt-get install clang libc++-dev
102
vjpai7cc2c302015-02-18 12:33:37 -0800103Mac-specific notes:
104-------------------
105
106For a Mac system, git is not available by default. You will first need to
107install Xcode from the Mac AppStore and then run the following command from a
108terminal:
109
110 $ sudo xcode-select --install
111
112You should also install "port" following the instructions at
113https://www.macports.org . This will reside in /opt/local/bin/port for
114most Mac installations. Do the "git submodule" command listed above.
115
116Then execute the following for all the needed build dependencies
117
118 $ sudo /opt/local/bin/port install autoconf automake libtool gflags cmake
119 $ mkdir ~/gtest
120 $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
121 $ mkdir mybuild
122 $ cd mybuild
123 $ cmake ../gtest-svn
124 $ make
125 $ make gtest.a gtest_main.a
126 $ sudo cp libgtest.a libgtest_main.a /opt/local/lib
127 $ sudo mkdir /opt/local/include/gtest
128 $ sudo cp -pr ../gtest-svn/include/gtest /opt/local/include/gtest
129
130We will also need to make openssl and install it appropriately
131
132 $ cd <git directory>
133 $ cd third_party/openssl
134 $ sudo make install
135 $ cd ../../
136
137If you are going to make changes and need to regenerate the projects file,
138you will need to install certain modules for python.
139
140 $ sudo easy_install simplejson mako
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800141
142A word on OpenSSL
143-----------------
nnoble0005b772014-12-10 16:25:34 -0800144
Abhishek Kumar3dd9df92015-02-10 10:16:41 -0800145Secure HTTP2 requires the TLS extension ALPN (see rfc 7301 and
nnoble0005b772014-12-10 16:25:34 -0800146http://http2.github.io/http2-spec/ section 3.3). Our HTTP2 implementation
Nicolas "Pixel" Nobled5660212015-01-23 20:35:49 +0100147relies on OpenSSL's implementation. OpenSSL 1.0.2 is the first released version
nnoble0005b772014-12-10 16:25:34 -0800148of OpenSSL that has ALPN support, and this explains our dependency on it.
149
nnoble69ac39f2014-12-12 15:43:38 -0800150Note that the Makefile supports compiling only the unsecure elements of grpc,
151and if you do not have OpenSSL and do not want it, you can still proceed
Abhishek Kumar6749e732015-02-10 10:59:52 -0800152with installing only the elements you require. However, we strongly recommend
Abhishek Kumar3dd9df92015-02-10 10:16:41 -0800153the use of encryption for all network traffic, and discourage the use of grpc
154without TLS.
nnoble69ac39f2014-12-12 15:43:38 -0800155
nnoble0005b772014-12-10 16:25:34 -0800156
157Compiling
158=========
159
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800160If you have all the dependencies mentioned above, you should simply be able
161to go ahead and run "make" to compile grpc's C and C++ libraries:
nnoble0005b772014-12-10 16:25:34 -0800162
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800163 $ make
nnoble0005b772014-12-10 16:25:34 -0800164
165
166Testing
167=======
168
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800169To build and run the tests, you can run the command:
nnoble0005b772014-12-10 16:25:34 -0800170
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800171 $ make test
172
173If you want to be able to run them in parallel, and get better output, you can
174also use the python tool we have written:
175
176 $ ./tools/run_tests/run_tests.py
nnoble0005b772014-12-10 16:25:34 -0800177
178
179Installing
180==========
181
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800182Once everything is compiled, you should be able to install grpc C and C++
nnoble0005b772014-12-10 16:25:34 -0800183libraries and headers:
184
Nicolas Noble6ae8ef12015-01-16 15:03:42 -0800185 # make install