aboutsummaryrefslogtreecommitdiffhomepage
path: root/INSTALL
blob: a0df57dcd35c86dd7be149256f91141833f7668b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
These instructions only cover building grpc C and C++ libraries under
typical unix systems. If you need more information, please try grpc's
wiki pages:

  https://github.com/google/grpc/wiki


*************************
* If you are in a hurry *
*************************

On Linux (Debian):

 Note: you will need to add the Debian 'jessie-backports' distribution to your sources
 file first.

 Add the following line to your `/etc/apt/sources.list` file:

   deb http://http.debian.net/debian jessie-backports main

 Install the gRPC library:

 $ [sudo] apt-get install libgrpc-dev

OR

 $ git clone https://github.com/grpc/grpc.git
 $ cd grpc
 $ git submodule update --init
 $ make 
 $ [sudo] make install

You don't need anything else than GNU Make, gcc and autotools. Under a Debian
or Ubuntu system, this should boil down to the following packages:

 $ [sudo] apt-get install build-essential autoconf libtool

Building the python wrapper requires the following:

 $ [sudo] apt-get install python-all-dev python-virtualenv

If you want to install in a different directory than the default /usr/lib, you can
override it on the command line:

 $ [sudo] make install prefix=/opt


*******************************
* More detailled instructions *
*******************************

Setting up dependencies
=======================

Dependencies to compile the libraries
-------------------------------------

grpc libraries have few external dependencies. If you need to compile and
install them, they are present in the third_party directory if you have
cloned the github repository recursively. If you didn't clone recursively,
you can still get them later by running the following command:

  $ git submodule update --init

Note that the Makefile makes it much easier for you to compile from sources
if you were to clone recursively our git repository: it will automatically
compile zlib and OpenSSL, which are core requirements for grpc. Note this
creates grpc libraries that will have zlib and OpenSSL built-in inside of them,
which significantly increases the libraries' size.

In order to decrease that size, you can manually install zlib and OpenSSL on
your system, so that the Makefile can use them instead.

Under a Debian or Ubuntu system, one can acquire the development package
for zlib this way:

  # apt-get install zlib1g-dev

To the best of our knowledge, no distribution has an OpenSSL package that
supports ALPN yet, so you would still have to depend on installing from source
for that particular dependency if you want to reduce the libraries' size.

The recommended version of OpenSSL that provides ALPN support is available
at this URL:

  https://www.openssl.org/source/openssl-1.0.2.tar.gz


Dependencies to compile and run the tests
-----------------------------------------

Compiling and running grpc plain-C tests dont't require any more dependency.


Compiling and running grpc C++ tests depend on protobuf 3.0.0, gtest and
gflags. Although gflags is provided in third_party, you will need to manually
install that dependency on your system to run these tests.

Under a Debian or Ubuntu system, you can install the gtests and gflags packages
using apt-get:

  # apt-get install libgflags-dev libgtest-dev

However, protobuf 3.0.0 isn't in a debian package yet, but the Makefile will
automatically try and compile the one present in third_party if you cloned the
repository recursively, and that it detects your system is lacking it.

Compiling and installing protobuf 3.0.0 requires a few more dependencies in
itself, notably the autoconf suite. If you have apt-get, you can install
these dependencies this way:

  # apt-get install autoconf libtool

If you want to run the tests using one of the sanitized configurations, you
will need clang and its instrumented libc++:

  # apt-get install clang libc++-dev

Mac-specific notes:
-------------------

For a Mac system, git is not available by default. You will first need to
install Xcode from the Mac AppStore and then run the following command from a
terminal:

  $ sudo xcode-select --install

You should also install "port" following the instructions at
https://www.macports.org . This will reside in /opt/local/bin/port for
most Mac installations. Do the "git submodule" command listed above.

Then execute the following for all the needed build dependencies

  $ sudo /opt/local/bin/port install autoconf automake libtool gflags cmake
  $ mkdir ~/gtest-svn
  $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
  $ mkdir mybuild
  $ cd mybuild
  $ cmake ../gtest-svn
  $ make
  $ make gtest.a gtest_main.a
  $ sudo cp libgtest.a libgtest_main.a /opt/local/lib
  $ sudo mkdir /opt/local/include/gtest
  $ sudo cp -pr ../gtest-svn/include/gtest /opt/local/include/gtest 

We will also need to make openssl and install it appropriately

  $ cd <git directory>
  $ cd third_party/openssl
  $ ./config
  $ sudo make install
  $ cd ../../

If you are going to make changes and need to regenerate the projects file,
you will need to install certain modules for python.

  $ sudo easy_install simplejson mako

Mingw-specific notes:
---------------------

While gRPC compiles properly under mingw, some more preparation work is needed.
The recommendation is to use msys2. The installation instructions are available
at that address: http://msys2.github.io/

Once this is installed, make sure you are using the following: MinGW-w64 Win64.
You'll be required to install a few more packages:

  $ pacman -S make mingw-w64-x86_64-gcc mingw-w64-x86_64-zlib autoconf automake libtool

Please also install OpenSSL from that website:

  http://slproweb.com/products/Win32OpenSSL.html

The package Win64 OpenSSL v1.0.2a should do. At that point you should be able
to compile gRPC with the following:

  $ export LDFLAGS="-L/mingw64/lib -L/c/OpenSSL-Win64"
  $ export CPPFLAGS="-I/mingw64/include -I/c/OpenSSL-Win64/include"
  $ make

A word on OpenSSL
-----------------

Secure HTTP2 requires the TLS extension ALPN (see rfc 7301 and
http://http2.github.io/http2-spec/ section 3.3). Our HTTP2 implementation
relies on OpenSSL's implementation. OpenSSL 1.0.2 is the first released version
of OpenSSL that has ALPN support, and this explains our dependency on it.

Note that the Makefile supports compiling only the unsecure elements of grpc,
and if you do not have OpenSSL and do not want it, you can still proceed
with installing only the elements you require. However, we strongly recommend
the use of encryption for all network traffic, and discourage the use of grpc
without TLS.


Compiling
=========

If you have all the dependencies mentioned above, you should simply be able
to go ahead and run "make" to compile grpc's C and C++ libraries:

  $ make


Testing
=======

To build and run the tests, you can run the command:

  $ make test

If you want to be able to run them in parallel, and get better output, you can
also use the python tool we have written:

  $ ./tools/run_tests/run_tests.py


Installing
==========

Once everything is compiled, you should be able to install grpc C and C++
libraries and headers:

  # make install