INSTALL 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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:
  4. https://github.com/google/grpc/wiki
  5. *************************
  6. * If you are in a hurry *
  7. *************************
  8. A typical unix installation won't require any more steps than running:
  9. $ make
  10. # make install
  11. You don't need anything else than GNU Make, gcc and autotools. Under a Debian
  12. or Ubuntu system, this should boil down to the following packages:
  13. # apt-get install build-essential autoconf libtool
  14. Building the python wrapper requires the following:
  15. # apt-get install python-all-dev python-virtualenv
  16. If you want to install in a different directory than the default /usr/lib, you can
  17. override it on the command line:
  18. # make install prefix=/opt
  19. *******************************
  20. * More detailled instructions *
  21. *******************************
  22. Setting up dependencies
  23. =======================
  24. Dependencies to compile the libraries
  25. -------------------------------------
  26. grpc libraries have few external dependencies. If you need to compile and
  27. install them, they are present in the third_party directory if you have
  28. cloned the github repository recursively. If you didn't clone recursively,
  29. you can still get them later by running the following command:
  30. $ git submodule update --init
  31. Note that the Makefile makes it much easier for you to compile from sources
  32. if you were to clone recursively our git repository: it will automatically
  33. compile zlib and OpenSSL, which are core requirements for grpc. Note this
  34. creates grpc libraries that will have zlib and OpenSSL built-in inside of them,
  35. which significantly increases the libraries' size.
  36. In order to decrease that size, you can manually install zlib and OpenSSL on
  37. your system, so that the Makefile can use them instead.
  38. Under a Debian or Ubuntu system, one can acquire the development package
  39. for zlib this way:
  40. # apt-get install zlib1g-dev
  41. To the best of our knowledge, no distribution has an OpenSSL package that
  42. supports ALPN yet, so you would still have to depend on installing from source
  43. for that particular dependency if you want to reduce the libraries' size.
  44. The recommended version of OpenSSL that provides ALPN support is available
  45. at this URL:
  46. https://www.openssl.org/source/openssl-1.0.2.tar.gz
  47. Dependencies to compile and run the tests
  48. -----------------------------------------
  49. Compiling and running grpc plain-C tests dont't require any more dependency.
  50. Compiling and running grpc C++ tests depend on protobuf 3.0.0, gtest and
  51. gflags. Although gflags is provided in third_party, you will need to manually
  52. install that dependency on your system to run these tests.
  53. Under a Debian or Ubuntu system, you can install the gtests and gflags packages
  54. using apt-get:
  55. # apt-get install libgflags-dev libgtest-dev
  56. However, protobuf 3.0.0 isn't in a debian package yet, but the Makefile will
  57. automatically try and compile the one present in third_party if you cloned the
  58. repository recursively, and that it detects your system is lacking it.
  59. Compiling and installing protobuf 3.0.0 requires a few more dependencies in
  60. itself, notably the autoconf suite. If you have apt-get, you can install
  61. these dependencies this way:
  62. # apt-get install autoconf libtool
  63. If you want to run the tests using one of the sanitized configurations, you
  64. will need clang and its instrumented libc++:
  65. # apt-get install clang libc++-dev
  66. Mac-specific notes:
  67. -------------------
  68. For a Mac system, git is not available by default. You will first need to
  69. install Xcode from the Mac AppStore and then run the following command from a
  70. terminal:
  71. $ sudo xcode-select --install
  72. You should also install "port" following the instructions at
  73. https://www.macports.org . This will reside in /opt/local/bin/port for
  74. most Mac installations. Do the "git submodule" command listed above.
  75. Then execute the following for all the needed build dependencies
  76. $ sudo /opt/local/bin/port install autoconf automake libtool gflags cmake
  77. $ mkdir ~/gtest
  78. $ svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn
  79. $ mkdir mybuild
  80. $ cd mybuild
  81. $ cmake ../gtest-svn
  82. $ make
  83. $ make gtest.a gtest_main.a
  84. $ sudo cp libgtest.a libgtest_main.a /opt/local/lib
  85. $ sudo mkdir /opt/local/include/gtest
  86. $ sudo cp -pr ../gtest-svn/include/gtest /opt/local/include/gtest
  87. We will also need to make openssl and install it appropriately
  88. $ cd <git directory>
  89. $ cd third_party/openssl
  90. $ sudo make install
  91. $ cd ../../
  92. If you are going to make changes and need to regenerate the projects file,
  93. you will need to install certain modules for python.
  94. $ sudo easy_install simplejson mako
  95. A word on OpenSSL
  96. -----------------
  97. Secure HTTP2 requires the TLS extension ALPN (see rfc 7301 and
  98. http://http2.github.io/http2-spec/ section 3.3). Our HTTP2 implementation
  99. relies on OpenSSL's implementation. OpenSSL 1.0.2 is the first released version
  100. of OpenSSL that has ALPN support, and this explains our dependency on it.
  101. Note that the Makefile supports compiling only the unsecure elements of grpc,
  102. and if you do not have OpenSSL and do not want it, you can still proceed
  103. with installing only the elements you require. However, we strongly recommend
  104. the use of encryption for all network traffic, and discourage the use of grpc
  105. without TLS.
  106. Compiling
  107. =========
  108. If you have all the dependencies mentioned above, you should simply be able
  109. to go ahead and run "make" to compile grpc's C and C++ libraries:
  110. $ make
  111. Testing
  112. =======
  113. To build and run the tests, you can run the command:
  114. $ make test
  115. If you want to be able to run them in parallel, and get better output, you can
  116. also use the python tool we have written:
  117. $ ./tools/run_tests/run_tests.py
  118. Installing
  119. ==========
  120. Once everything is compiled, you should be able to install grpc C and C++
  121. libraries and headers:
  122. # make install