1# Packaging `google-cloud-cpp`
2
3<!-- This is an automatically generated file -->
4<!-- Make changes in ci/generate-markdown/generate-packaging.sh -->
5
6This document is intended for package maintainers or for people who might like
7to "install" the `google-cloud-cpp` libraries.
8
9There are two primary ways of obtaining `google-cloud-cpp`. You can use git:
10
11```bash
12git clone https://github.com/googleapis/google-cloud-cpp.git $HOME/google-cloud-cpp
13```
14
15Or obtain the tarball release (see
16https://github.com/googleapis/google-cloud-cpp/releases for the latest
17release):
18
19```bash
20VERSION="vX.Y.Z"
21mkdir -p $HOME/google-cloud-cpp
22wget -q https://github.com/googleapis/google-cloud-cpp/archive/${VERSION}.tar.gz
23tar -xf ${VERSION}.tar.gz -C $HOME/google-cloud-cpp --strip=1
24```
25
26# Installing `google-cloud-cpp`
27
28<!-- This is an automatically generated file -->
29<!-- Make changes in ci/generate-markdown/generate-packaging.sh -->
30
31By default `google-cloud-cpp` libraries download and compile all their
32dependencies ([see below](#required-libraries) for a complete list). This makes
33it easier for users to "take the library for a spin", and works well for users
34that "Live at Head", but does not work for package maintainers or users that
35prefer to compile their dependencies once and install them in `/usr/local/` or
36a similar directory.
37
38This document provides instructions to install the dependencies of
39`google-cloud-cpp`.
40
41**If** all the dependencies of `google-cloud-cpp` are installed and provide
42CMake support files, then compiling and installing the libraries
43requires two commands:
44
45```bash
46cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
47cmake --build cmake-out --target install
48```
49
50You may choose to parallelize the build by appending `-- -j ${NCPU}` to the
51build command, where `NCPU` is an environment variable set to the number of
52processors on your system. On Linux, you can obtain this information using the
53`nproc` command or `sysctl -n hw.physicalcpu` on Mac.
54
55Unfortunately getting your system to this state may require multiple steps,
56the following sections describe how to install `google-cloud-cpp` on several
57platforms.
58
59## Using `google-cloud-cpp` in CMake-based projects.
60
61Once you have installed `google-cloud-cpp` you can use the libraries from
62your own projects using `find_package()` in your `CMakeLists.txt` file:
63
64```CMake
65cmake_minimum_required(VERSION 3.5)
66
67find_package(storage_client REQUIRED)
68
69add_executable(my_program my_program.cc)
70target_link_libraries(my_program storage_client)
71```
72
73You can use a similar `CMakeLists.txt` to use the Cloud Bigtable C++ client:
74
75```CMake
76cmake_minimum_required(VERSION 3.5)
77
78find_package(bigtable_client REQUIRED)
79
80add_executable(my_program my_program.cc)
81target_link_libraries(my_program bigtable_client)
82```
83
84## Using `google-cloud-cpp` in Make-based projects.
85
86Once you have installed `google-cloud-cpp` you can use the libraries in your
87own Make-based projects using `pkg-config`:
88
89```Makefile
90GCS_CXXFLAGS   := $(shell pkg-config storage_client --cflags)
91GCS_CXXLDFLAGS := $(shell pkg-config storage_client --libs-only-L)
92GCS_LIBS       := $(shell pkg-config storage_client --libs-only-l)
93
94my_storage_program: my_storage_program.cc
95        $(CXX) $(CXXFLAGS) $(GCS_CXXFLAGS) $(GCS_CXXLDFLAGS) -o $@ $^ $(GCS_LIBS)
96
97CBT_CXXFLAGS   := $(shell pkg-config bigtable_client --cflags)
98CBT_CXXLDFLAGS := $(shell pkg-config bigtable_client --libs-only-L)
99CBT_LIBS       := $(shell pkg-config bigtable_client --libs-only-l)
100
101my_bigtable_program: my_bigtable_program.cc
102        $(CXX) $(CXXFLAGS) $(CBT_CXXFLAGS) $(CBT_CXXLDFLAGS) -o $@ $^ $(CBT_LIBS)
103```
104
105## Using `google-cloud-cpp` in Bazel-based projects.
106
107If you use `Bazel` for your builds you do not need to install
108`google-cloud-cpp`. We provide a Starlark function to automatically download and
109compile `google-cloud-cpp` as part of you Bazel build. Add the following
110commands to your `WORKSPACE` file:
111
112```Python
113# Update the version and SHA256 digest as needed.
114http_archive(
115    name = "com_github_googleapis_google_cloud_cpp",
116    url = "http://github.com/googleapis/google-cloud-cpp/archive/v1.19.0.tar.gz",
117    strip_prefix = "google-cloud-cpp-1.19.0",
118    sha256 = "33eb349cf5f033704a4299b0ac57e3a8b4973ca92f4491aef822bfeb41e69d27",
119)
120
121load("@com_github_googleapis_google_cloud_cpp//bazel:google_cloud_cpp_deps.bzl", "google_cloud_cpp_deps")
122google_cloud_cpp_deps()
123# Have to manually call the corresponding function for gRPC:
124#   https://github.com/bazelbuild/bazel/issues/1550
125load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
126grpc_deps()
127load("@upb//bazel:workspace_deps.bzl", "upb_deps")
128upb_deps()
129load("@build_bazel_rules_apple//apple:repositories.bzl", "apple_rules_dependencies")
130apple_rules_dependencies()
131load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
132apple_support_dependencies()
133```
134
135Then you can link the libraries from your `BUILD` files:
136
137```Python
138cc_binary(
139    name = "bigtable_install_test",
140    srcs = [
141        "bigtable_install_test.cc",
142    ],
143    deps = [
144        "@com_github_googleapis_google_cloud_cpp//google/cloud/bigtable:bigtable_client",
145    ],
146)
147
148cc_binary(
149    name = "storage_install_test",
150    srcs = [
151        "storage_install_test.cc",
152    ],
153    deps = [
154        "@com_github_googleapis_google_cloud_cpp//google/cloud/storage:storage_client",
155    ],
156)
157```
158
159## Required Libraries
160
161`google-cloud-cpp` directly depends on the following libraries:
162
163| Library | Minimum version | Description |
164| ------- | --------------: | ----------- |
165| [gRPC][gRPC-gh] | 1.16.x | gRPC++ for Cloud Bigtable |
166| [libcurl][libcurl-gh] | 7.47.0  | HTTP client library for the Google Cloud Storage client |
167| [crc32c][crc32c-gh]  | 1.0.6 | Hardware-accelerated CRC32C implementation |
168| [OpenSSL][OpenSSL-gh] | 1.0.2 | Crypto functions for Google Cloud Storage authentication |
169| [nlohmann/json][nlohmann-json-gh] | 3.4.0 | JSON for Modern C++ |
170
171[gRPC-gh]: https://github.com/grpc/grpc
172[libcurl-gh]: https://github.com/curl/curl
173[crc32c-gh]: https://github.com/google/crc32c
174[OpenSSL-gh]: https://github.com/openssl/openssl
175[nlohmann-json-gh]: https://github.com/nlohmann/json
176
177Note that these libraries may also depend on other libraries. The following
178instructions include steps to install these indirect dependencies too.
179
180When possible, the instructions below prefer to use pre-packaged versions of
181these libraries and their dependencies. In some cases the packages do not exist,
182or the package versions are too old to support `google-cloud-cpp`. If this is
183the case, the instructions describe how you can manually download and install
184these dependencies.
185
186## Table of Contents
187
188- [Fedora 33](#fedora-33)
189- [openSUSE (Tumbleweed)](#opensuse-tumbleweed)
190- [openSUSE (Leap)](#opensuse-leap)
191- [Ubuntu (20.04 LTS - Focal Fossa)](#ubuntu-2004-lts---focal-fossa)
192- [Ubuntu (18.04 LTS - Bionic Beaver)](#ubuntu-1804-lts---bionic-beaver)
193- [Ubuntu (16.04 LTS - Xenial Xerus)](#ubuntu-1604-lts---xenial-xerus)
194- [Debian (Buster)](#debian-buster)
195- [Debian (Stretch)](#debian-stretch)
196- [CentOS 8](#centos-8)
197- [CentOS 7](#centos-7)
198
199### Fedora (33)
200
201Install the minimal development tools:
202
203```bash
204sudo dnf makecache && \
205sudo dnf install -y ccache cmake gcc-c++ git make openssl-devel pkgconfig \
206        zlib-devel
207```
208
209Fedora 31 includes packages for gRPC, libcurl, and OpenSSL that are recent
210enough for the project. Install these packages and additional development
211tools to compile the dependencies:
212
213```bash
214sudo dnf makecache && \
215sudo dnf install -y grpc-devel grpc-plugins \
216        libcurl-devel protobuf-compiler tar wget zlib-devel
217```
218
219The following steps will install libraries and tools in `/usr/local`. By
220default pkg-config does not search in these directories.
221
222```bash
223export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
224```
225
226#### Abseil
227
228We need a recent version of Abseil.
229
230```bash
231cd $HOME/Downloads
232wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
233    tar -xf 20200225.2.tar.gz && \
234    cd abseil-cpp-20200225.2 && \
235    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
236    cmake \
237      -DCMAKE_BUILD_TYPE=Release \
238      -DBUILD_TESTING=OFF \
239      -DBUILD_SHARED_LIBS=yes \
240      -DCMAKE_CXX_STANDARD=11 \
241      -H. -Bcmake-out && \
242    cmake --build cmake-out -- -j ${NCPU:-4} && \
243sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
244sudo ldconfig
245```
246
247#### crc32c
248
249The project depends on the Crc32c library, we need to compile this from
250source:
251
252```bash
253cd $HOME/Downloads
254wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
255    tar -xf 1.1.0.tar.gz && \
256    cd crc32c-1.1.0 && \
257    cmake \
258        -DCMAKE_BUILD_TYPE=Release \
259        -DBUILD_SHARED_LIBS=yes \
260        -DCRC32C_BUILD_TESTS=OFF \
261        -DCRC32C_BUILD_BENCHMARKS=OFF \
262        -DCRC32C_USE_GLOG=OFF \
263        -H. -Bcmake-out && \
264    cmake --build cmake-out -- -j ${NCPU:-4} && \
265sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
266sudo ldconfig
267```
268
269#### nlohmann_json library
270
271The project depends on the nlohmann_json library. We use CMake to
272install it as this installs the necessary CMake configuration files.
273Note that this is a header-only library, and often installed manually.
274This leaves your environment without support for CMake pkg-config.
275
276```bash
277cd $HOME/Downloads
278wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
279    tar -xzf v3.9.0.tar.gz && \
280    cd json-3.9.0 && \
281    cmake \
282      -DCMAKE_BUILD_TYPE=Release \
283      -DBUILD_SHARED_LIBS=yes \
284      -DBUILD_TESTING=OFF \
285      -H. -Bcmake-out/nlohmann/json && \
286sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
287sudo ldconfig
288```
289
290#### Compile and install the main project
291
292We can now compile, test, and install `google-cloud-cpp`.
293
294```bash
295cd $HOME/google-cloud-cpp
296cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
297cmake --build cmake-out -- -j "${NCPU:-4}"
298sudo cmake --build cmake-out --target install
299```
300
301
302### openSUSE (Tumbleweed)
303
304Install the minimal development tools, libcurl and OpenSSL:
305
306```bash
307sudo zypper refresh && \
308sudo zypper install --allow-downgrade -y c-ares-devel ccache cmake gcc gcc-c++ \
309        git gzip libcurl-devel libopenssl-devel make tar wget zlib-devel
310```
311
312The version of Protobuf packaged with openSUSE/Tumbleweed is recent enough to
313support the Google Cloud Platform proto files. However, the version of gRPC
314packaged with opensuse/Tumbleweed incorrectly installs partial Abseil binary
315artifacts, so we cannot use that package and must instead install Abseil and
316gRPC from source.
317
318```bash
319sudo zypper refresh && \
320sudo zypper install -y protobuf-devel
321```
322
323The following steps will install libraries and tools in `/usr/local`. By
324default pkg-config does not search in these directories.
325
326```bash
327export PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig
328```
329
330#### Abseil
331
332We need a recent version of Abseil.
333
334```bash
335cd $HOME/Downloads
336wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
337    tar -xf 20200225.2.tar.gz && \
338    cd abseil-cpp-20200225.2 && \
339    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
340    cmake \
341      -DCMAKE_BUILD_TYPE=Release \
342      -DBUILD_TESTING=OFF \
343      -DBUILD_SHARED_LIBS=yes \
344      -DCMAKE_CXX_STANDARD=11 \
345      -H. -Bcmake-out && \
346    cmake --build cmake-out -- -j ${NCPU:-4} && \
347sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
348sudo ldconfig
349```
350
351#### gRPC
352
353We also need a version of gRPC that is recent enough to support the Google
354Cloud Platform proto files. We manually install it using:
355
356```bash
357cd $HOME/Downloads
358wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
359    tar -xf v1.29.1.tar.gz && \
360    cd grpc-1.29.1 && \
361    cmake \
362        -DCMAKE_BUILD_TYPE=Release \
363        -DgRPC_INSTALL=ON \
364        -DgRPC_BUILD_TESTS=OFF \
365        -DgRPC_ABSL_PROVIDER=package \
366        -DgRPC_CARES_PROVIDER=package \
367        -DgRPC_PROTOBUF_PROVIDER=package \
368        -DgRPC_SSL_PROVIDER=package \
369        -DgRPC_ZLIB_PROVIDER=package \
370        -H. -Bcmake-out && \
371    cmake --build cmake-out -- -j ${NCPU:-4} && \
372sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
373sudo ldconfig
374```
375
376#### crc32c
377
378The project depends on the Crc32c library, we need to compile this from
379source:
380
381```bash
382cd $HOME/Downloads
383wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
384    tar -xf 1.1.0.tar.gz && \
385    cd crc32c-1.1.0 && \
386    cmake \
387        -DCMAKE_BUILD_TYPE=Release \
388        -DBUILD_SHARED_LIBS=yes \
389        -DCRC32C_BUILD_TESTS=OFF \
390        -DCRC32C_BUILD_BENCHMARKS=OFF \
391        -DCRC32C_USE_GLOG=OFF \
392        -H. -Bcmake-out && \
393    cmake --build cmake-out -- -j ${NCPU:-4} && \
394sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
395sudo ldconfig
396```
397
398#### nlohmann_json library
399
400The project depends on the nlohmann_json library. We use CMake to
401install it as this installs the necessary CMake configuration files.
402Note that this is a header-only library, and often installed manually.
403This leaves your environment without support for CMake pkg-config.
404
405```bash
406cd $HOME/Downloads
407wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
408    tar -xzf v3.9.0.tar.gz && \
409    cd json-3.9.0 && \
410    cmake \
411      -DCMAKE_BUILD_TYPE=Release \
412      -DBUILD_SHARED_LIBS=yes \
413      -DBUILD_TESTING=OFF \
414      -H. -Bcmake-out/nlohmann/json && \
415sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
416sudo ldconfig
417```
418
419#### Compile and install the main project
420
421We can now compile, test, and install `google-cloud-cpp`.
422
423```bash
424cd $HOME/google-cloud-cpp
425cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
426cmake --build cmake-out -- -j "${NCPU:-4}"
427sudo cmake --build cmake-out --target install
428```
429
430
431### openSUSE (Leap)
432
433Install the minimal development tools, libcurl and OpenSSL. The gRPC Makefile
434uses `which` to determine whether the compiler is available. Install this
435command for the extremely rare case where it may be missing from your
436workstation or build server.
437
438```bash
439sudo zypper refresh && \
440sudo zypper install --allow-downgrade -y automake ccache cmake gcc gcc-c++ git \
441        gzip libcurl-devel libopenssl-devel libtool make tar wget which \
442        zlib zlib-devel-static
443```
444
445The following steps will install libraries and tools in `/usr/local`. openSUSE
446does not search for shared libraries in these directories by default, there
447are multiple ways to solve this problem, the following steps are one solution:
448
449```bash
450(echo "/usr/local/lib" ; echo "/usr/local/lib64") | \
451sudo tee /etc/ld.so.conf.d/usrlocal.conf
452export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
453export PATH=/usr/local/bin:${PATH}
454```
455
456#### Abseil
457
458We need a recent version of Abseil.
459
460```bash
461cd $HOME/Downloads
462wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
463    tar -xf 20200225.2.tar.gz && \
464    cd abseil-cpp-20200225.2 && \
465    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
466    cmake \
467      -DCMAKE_BUILD_TYPE=Release \
468      -DBUILD_TESTING=OFF \
469      -DBUILD_SHARED_LIBS=yes \
470      -DCMAKE_CXX_STANDARD=11 \
471      -H. -Bcmake-out && \
472    cmake --build cmake-out -- -j ${NCPU:-4} && \
473sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
474sudo ldconfig
475```
476
477#### Protobuf
478
479We need to install a version of Protobuf that is recent enough to support the
480Google Cloud Platform proto files:
481
482```bash
483cd $HOME/Downloads
484wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
485    tar -xf v3.11.3.tar.gz && \
486    cd protobuf-3.11.3/cmake && \
487    cmake \
488        -DCMAKE_BUILD_TYPE=Release \
489        -DBUILD_SHARED_LIBS=yes \
490        -Dprotobuf_BUILD_TESTS=OFF \
491        -H. -Bcmake-out && \
492    cmake --build cmake-out -- -j ${NCPU:-4} && \
493sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
494sudo ldconfig
495```
496
497#### c-ares
498
499Recent versions of gRPC require c-ares >= 1.11, while openSUSE/Leap
500distributes c-ares-1.9. Manually install a newer version:
501
502```bash
503cd $HOME/Downloads
504wget -q https://github.com/c-ares/c-ares/archive/cares-1_14_0.tar.gz && \
505    tar -xf cares-1_14_0.tar.gz && \
506    cd c-ares-cares-1_14_0 && \
507    ./buildconf && ./configure && make -j ${NCPU:-4} && \
508sudo make install && \
509sudo ldconfig
510```
511
512#### gRPC
513
514We also need a version of gRPC that is recent enough to support the Google
515Cloud Platform proto files. We manually install it using:
516
517```bash
518cd $HOME/Downloads
519wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
520    tar -xf v1.29.1.tar.gz && \
521    cd grpc-1.29.1 && \
522    cmake \
523        -DCMAKE_BUILD_TYPE=Release \
524        -DgRPC_INSTALL=ON \
525        -DgRPC_BUILD_TESTS=OFF \
526        -DgRPC_ABSL_PROVIDER=package \
527        -DgRPC_CARES_PROVIDER=package \
528        -DgRPC_PROTOBUF_PROVIDER=package \
529        -DgRPC_SSL_PROVIDER=package \
530        -DgRPC_ZLIB_PROVIDER=package \
531        -H. -Bcmake-out && \
532    cmake --build cmake-out -- -j ${NCPU:-4} && \
533sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
534sudo ldconfig
535```
536
537#### crc32c
538
539The project depends on the Crc32c library, we need to compile this from
540source:
541
542```bash
543cd $HOME/Downloads
544wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
545    tar -xf 1.1.0.tar.gz && \
546    cd crc32c-1.1.0 && \
547    cmake \
548        -DCMAKE_BUILD_TYPE=Release \
549        -DBUILD_SHARED_LIBS=yes \
550        -DCRC32C_BUILD_TESTS=OFF \
551        -DCRC32C_BUILD_BENCHMARKS=OFF \
552        -DCRC32C_USE_GLOG=OFF \
553        -H. -Bcmake-out && \
554    cmake --build cmake-out -- -j ${NCPU:-4} && \
555sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
556sudo ldconfig
557```
558
559#### nlohmann_json library
560
561The project depends on the nlohmann_json library. We use CMake to
562install it as this installs the necessary CMake configuration files.
563Note that this is a header-only library, and often installed manually.
564This leaves your environment without support for CMake pkg-config.
565
566```bash
567cd $HOME/Downloads
568wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
569    tar -xzf v3.9.0.tar.gz && \
570    cd json-3.9.0 && \
571    cmake \
572      -DCMAKE_BUILD_TYPE=Release \
573      -DBUILD_SHARED_LIBS=yes \
574      -DBUILD_TESTING=OFF \
575      -H. -Bcmake-out/nlohmann/json && \
576sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
577sudo ldconfig
578```
579
580#### Compile and install the main project
581
582We can now compile, test, and install `google-cloud-cpp`.
583
584```bash
585cd $HOME/google-cloud-cpp
586cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
587cmake --build cmake-out -- -j "${NCPU:-4}"
588sudo cmake --build cmake-out --target install
589```
590
591
592### Ubuntu (20.04 LTS - Focal Fossa)
593
594Install the minimal development tools, libcurl, OpenSSL and libc-ares:
595
596```bash
597export DEBIAN_FRONTEND=noninteractive
598sudo apt-get update && \
599sudo apt-get --no-install-recommends install -y apt-transport-https apt-utils \
600        automake build-essential ccache cmake ca-certificates git gcc g++ \
601        libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev m4 make \
602        pkg-config tar wget zlib1g-dev
603```
604
605#### Abseil
606
607We need a recent version of Abseil.
608
609```bash
610cd $HOME/Downloads
611wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
612    tar -xf 20200225.2.tar.gz && \
613    cd abseil-cpp-20200225.2 && \
614    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
615    cmake \
616      -DCMAKE_BUILD_TYPE=Release \
617      -DBUILD_TESTING=OFF \
618      -DBUILD_SHARED_LIBS=yes \
619      -DCMAKE_CXX_STANDARD=11 \
620      -H. -Bcmake-out && \
621    cmake --build cmake-out -- -j ${NCPU:-4} && \
622sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
623sudo ldconfig
624```
625
626#### Protobuf
627
628We need to install a version of Protobuf that is recent enough to support the
629Google Cloud Platform proto files:
630
631```bash
632cd $HOME/Downloads
633wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
634    tar -xf v3.11.3.tar.gz && \
635    cd protobuf-3.11.3/cmake && \
636    cmake \
637        -DCMAKE_BUILD_TYPE=Release \
638        -DBUILD_SHARED_LIBS=yes \
639        -Dprotobuf_BUILD_TESTS=OFF \
640        -H. -Bcmake-out && \
641    cmake --build cmake-out -- -j ${NCPU:-4} && \
642sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
643sudo ldconfig
644```
645
646#### gRPC
647
648We also need a version of gRPC that is recent enough to support the Google
649Cloud Platform proto files. We install it using:
650
651```bash
652cd $HOME/Downloads
653wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
654    tar -xf v1.29.1.tar.gz && \
655    cd grpc-1.29.1 && \
656    cmake \
657        -DCMAKE_BUILD_TYPE=Release \
658        -DgRPC_INSTALL=ON \
659        -DgRPC_BUILD_TESTS=OFF \
660        -DgRPC_ABSL_PROVIDER=package \
661        -DgRPC_CARES_PROVIDER=package \
662        -DgRPC_PROTOBUF_PROVIDER=package \
663        -DgRPC_SSL_PROVIDER=package \
664        -DgRPC_ZLIB_PROVIDER=package \
665        -H. -Bcmake-out && \
666    cmake --build cmake-out -- -j ${NCPU:-4} && \
667sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
668sudo ldconfig
669```
670
671#### crc32c
672
673The project depends on the Crc32c library, we need to compile this from
674source:
675
676```bash
677cd $HOME/Downloads
678wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
679    tar -xf 1.1.0.tar.gz && \
680    cd crc32c-1.1.0 && \
681    cmake \
682        -DCMAKE_BUILD_TYPE=Release \
683        -DBUILD_SHARED_LIBS=yes \
684        -DCRC32C_BUILD_TESTS=OFF \
685        -DCRC32C_BUILD_BENCHMARKS=OFF \
686        -DCRC32C_USE_GLOG=OFF \
687        -H. -Bcmake-out && \
688    cmake --build cmake-out -- -j ${NCPU:-4} && \
689sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
690sudo ldconfig
691```
692
693#### nlohmann_json library
694
695The project depends on the nlohmann_json library. We use CMake to
696install it as this installs the necessary CMake configuration files.
697Note that this is a header-only library, and often installed manually.
698This leaves your environment without support for CMake pkg-config.
699
700```bash
701cd $HOME/Downloads
702wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
703    tar -xzf v3.9.0.tar.gz && \
704    cd json-3.9.0 && \
705    cmake \
706      -DCMAKE_BUILD_TYPE=Release \
707      -DBUILD_SHARED_LIBS=yes \
708      -DBUILD_TESTING=OFF \
709      -H. -Bcmake-out/nlohmann/json && \
710sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
711sudo ldconfig
712```
713
714#### Compile and install the main project
715
716We can now compile, test, and install `google-cloud-cpp`.
717
718```bash
719cd $HOME/google-cloud-cpp
720cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
721cmake --build cmake-out -- -j "${NCPU:-4}"
722sudo cmake --build cmake-out --target install
723```
724
725
726### Ubuntu (18.04 LTS - Bionic Beaver)
727
728Install the minimal development tools, libcurl, OpenSSL and libc-ares:
729
730```bash
731sudo apt-get update && \
732sudo apt-get --no-install-recommends install -y apt-transport-https apt-utils \
733        automake build-essential ccache cmake ca-certificates git gcc g++ \
734        libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev m4 make \
735        pkg-config tar wget zlib1g-dev
736```
737
738#### Abseil
739
740We need a recent version of Abseil.
741
742```bash
743cd $HOME/Downloads
744wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
745    tar -xf 20200225.2.tar.gz && \
746    cd abseil-cpp-20200225.2 && \
747    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
748    cmake \
749      -DCMAKE_BUILD_TYPE=Release \
750      -DBUILD_TESTING=OFF \
751      -DBUILD_SHARED_LIBS=yes \
752      -DCMAKE_CXX_STANDARD=11 \
753      -H. -Bcmake-out && \
754    cmake --build cmake-out -- -j ${NCPU:-4} && \
755sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
756sudo ldconfig
757```
758
759#### Protobuf
760
761We need to install a version of Protobuf that is recent enough to support the
762Google Cloud Platform proto files:
763
764```bash
765cd $HOME/Downloads
766wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
767    tar -xf v3.11.3.tar.gz && \
768    cd protobuf-3.11.3/cmake && \
769    cmake \
770        -DCMAKE_BUILD_TYPE=Release \
771        -DBUILD_SHARED_LIBS=yes \
772        -Dprotobuf_BUILD_TESTS=OFF \
773        -H. -Bcmake-out && \
774    cmake --build cmake-out -- -j ${NCPU:-4} && \
775sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
776sudo ldconfig
777```
778
779#### gRPC
780
781We also need a version of gRPC that is recent enough to support the Google
782Cloud Platform proto files. We install it using:
783
784```bash
785cd $HOME/Downloads
786wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
787    tar -xf v1.29.1.tar.gz && \
788    cd grpc-1.29.1 && \
789    cmake \
790        -DCMAKE_BUILD_TYPE=Release \
791        -DgRPC_INSTALL=ON \
792        -DgRPC_BUILD_TESTS=OFF \
793        -DgRPC_ABSL_PROVIDER=package \
794        -DgRPC_CARES_PROVIDER=package \
795        -DgRPC_PROTOBUF_PROVIDER=package \
796        -DgRPC_SSL_PROVIDER=package \
797        -DgRPC_ZLIB_PROVIDER=package \
798        -H. -Bcmake-out && \
799    cmake --build cmake-out -- -j ${NCPU:-4} && \
800sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
801sudo ldconfig
802```
803
804#### crc32c
805
806The project depends on the Crc32c library, we need to compile this from
807source:
808
809```bash
810cd $HOME/Downloads
811wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
812    tar -xf 1.1.0.tar.gz && \
813    cd crc32c-1.1.0 && \
814    cmake \
815        -DCMAKE_BUILD_TYPE=Release \
816        -DBUILD_SHARED_LIBS=yes \
817        -DCRC32C_BUILD_TESTS=OFF \
818        -DCRC32C_BUILD_BENCHMARKS=OFF \
819        -DCRC32C_USE_GLOG=OFF \
820        -H. -Bcmake-out && \
821    cmake --build cmake-out -- -j ${NCPU:-4} && \
822sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
823sudo ldconfig
824```
825
826#### nlohmann_json library
827
828The project depends on the nlohmann_json library. We use CMake to
829install it as this installs the necessary CMake configuration files.
830Note that this is a header-only library, and often installed manually.
831This leaves your environment without support for CMake pkg-config.
832
833```bash
834cd $HOME/Downloads
835wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
836    tar -xzf v3.9.0.tar.gz && \
837    cd json-3.9.0 && \
838    cmake \
839      -DCMAKE_BUILD_TYPE=Release \
840      -DBUILD_SHARED_LIBS=yes \
841      -DBUILD_TESTING=OFF \
842      -H. -Bcmake-out/nlohmann/json && \
843sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
844sudo ldconfig
845```
846
847#### Compile and install the main project
848
849We can now compile, test, and install `google-cloud-cpp`.
850
851```bash
852cd $HOME/google-cloud-cpp
853cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
854cmake --build cmake-out -- -j "${NCPU:-4}"
855sudo cmake --build cmake-out --target install
856```
857
858
859### Ubuntu (16.04 LTS - Xenial Xerus)
860
861Install the minimal development tools, OpenSSL and libcurl:
862
863```bash
864sudo apt-get update && \
865sudo apt-get --no-install-recommends install -y apt-transport-https apt-utils \
866        automake build-essential ccache cmake ca-certificates git gcc g++ \
867        libcurl4-openssl-dev libssl-dev libtool m4 make \
868        pkg-config tar wget zlib1g-dev
869```
870
871#### Abseil
872
873We need a recent version of Abseil.
874
875```bash
876cd $HOME/Downloads
877wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
878    tar -xf 20200225.2.tar.gz && \
879    cd abseil-cpp-20200225.2 && \
880    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
881    cmake \
882      -DCMAKE_BUILD_TYPE=Release \
883      -DBUILD_TESTING=OFF \
884      -DBUILD_SHARED_LIBS=yes \
885      -DCMAKE_CXX_STANDARD=11 \
886      -H. -Bcmake-out && \
887    cmake --build cmake-out -- -j ${NCPU:-4} && \
888sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
889sudo ldconfig
890```
891
892#### Protobuf
893
894We need to install a version of Protobuf that is recent enough to support the
895Google Cloud Platform proto files:
896
897```bash
898cd $HOME/Downloads
899wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
900    tar -xf v3.11.3.tar.gz && \
901    cd protobuf-3.11.3/cmake && \
902    cmake \
903        -DCMAKE_BUILD_TYPE=Release \
904        -DBUILD_SHARED_LIBS=yes \
905        -Dprotobuf_BUILD_TESTS=OFF \
906        -H. -Bcmake-out && \
907    cmake --build cmake-out -- -j ${NCPU:-4} && \
908sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
909sudo ldconfig
910```
911
912#### c-ares
913
914Recent versions of gRPC require c-ares >= 1.11, while Ubuntu-16.04
915distributes c-ares-1.10. Manually install a newer version:
916
917```bash
918cd $HOME/Downloads
919wget -q https://github.com/c-ares/c-ares/archive/cares-1_14_0.tar.gz && \
920    tar -xf cares-1_14_0.tar.gz && \
921    cd c-ares-cares-1_14_0 && \
922    ./buildconf && ./configure && make -j ${NCPU:-4} && \
923sudo make install && \
924sudo ldconfig
925```
926
927#### gRPC
928
929We also need a version of gRPC that is recent enough to support the Google
930Cloud Platform proto files. We can install gRPC from source using:
931
932```bash
933cd $HOME/Downloads
934wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
935    tar -xf v1.29.1.tar.gz && \
936    cd grpc-1.29.1 && \
937    cmake \
938        -DCMAKE_BUILD_TYPE=Release \
939        -DgRPC_INSTALL=ON \
940        -DgRPC_BUILD_TESTS=OFF \
941        -DgRPC_ABSL_PROVIDER=package \
942        -DgRPC_CARES_PROVIDER=package \
943        -DgRPC_PROTOBUF_PROVIDER=package \
944        -DgRPC_SSL_PROVIDER=package \
945        -DgRPC_ZLIB_PROVIDER=package \
946        -H. -Bcmake-out && \
947    cmake --build cmake-out -- -j ${NCPU:-4} && \
948sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
949sudo ldconfig
950```
951
952#### crc32c
953
954The project depends on the Crc32c library, we need to compile this from
955source:
956
957```bash
958cd $HOME/Downloads
959wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
960    tar -xf 1.1.0.tar.gz && \
961    cd crc32c-1.1.0 && \
962    cmake \
963        -DCMAKE_BUILD_TYPE=Release \
964        -DBUILD_SHARED_LIBS=yes \
965        -DCRC32C_BUILD_TESTS=OFF \
966        -DCRC32C_BUILD_BENCHMARKS=OFF \
967        -DCRC32C_USE_GLOG=OFF \
968        -H. -Bcmake-out && \
969    cmake --build cmake-out -- -j ${NCPU:-4} && \
970sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
971sudo ldconfig
972```
973
974#### nlohmann_json library
975
976The project depends on the nlohmann_json library. We use CMake to
977install it as this installs the necessary CMake configuration files.
978Note that this is a header-only library, and often installed manually.
979This leaves your environment without support for CMake pkg-config.
980
981```bash
982cd $HOME/Downloads
983wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
984    tar -xzf v3.9.0.tar.gz && \
985    cd json-3.9.0 && \
986    sed -i \
987        -e '1s/VERSION 3.8/VERSION 3.5/' \
988        -e '/^target_compile_features/d' \
989        CMakeLists.txt && \
990    cmake \
991      -DCMAKE_BUILD_TYPE=Release \
992      -DBUILD_SHARED_LIBS=yes \
993      -DBUILD_TESTING=OFF \
994      -H. -Bcmake-out/nlohmann/json && \
995sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
996sudo ldconfig
997```
998
999#### Compile and install the main project
1000
1001We can now compile, test, and install `google-cloud-cpp`.
1002
1003```bash
1004cd $HOME/google-cloud-cpp
1005cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
1006cmake --build cmake-out -- -j "${NCPU:-4}"
1007sudo cmake --build cmake-out --target install
1008```
1009
1010
1011### Debian (Buster)
1012
1013Install the minimal development tools, libcurl, and OpenSSL:
1014
1015```bash
1016sudo apt-get update && \
1017sudo apt-get --no-install-recommends install -y apt-transport-https apt-utils \
1018        automake build-essential ca-certificates ccache cmake git gcc g++ \
1019        libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev m4 make \
1020        pkg-config tar wget zlib1g-dev
1021```
1022
1023Debian 10 includes versions of gRPC and Protobuf that support the
1024Google Cloud Platform proto files. We simply install these pre-built versions:
1025
1026```bash
1027sudo apt-get update && \
1028sudo apt-get --no-install-recommends install -y libgrpc++-dev libprotobuf-dev \
1029    libprotoc-dev libc-ares-dev protobuf-compiler protobuf-compiler-grpc
1030```
1031
1032#### Abseil
1033
1034We need a recent version of Abseil.
1035
1036```bash
1037cd $HOME/Downloads
1038wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
1039    tar -xf 20200225.2.tar.gz && \
1040    cd abseil-cpp-20200225.2 && \
1041    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
1042    cmake \
1043      -DCMAKE_BUILD_TYPE=Release \
1044      -DBUILD_TESTING=OFF \
1045      -DBUILD_SHARED_LIBS=yes \
1046      -DCMAKE_CXX_STANDARD=11 \
1047      -H. -Bcmake-out && \
1048    cmake --build cmake-out -- -j ${NCPU:-4} && \
1049sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1050sudo ldconfig
1051```
1052
1053#### crc32c
1054
1055The project depends on the Crc32c library, we need to compile this from
1056source:
1057
1058```bash
1059cd $HOME/Downloads
1060wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
1061    tar -xf 1.1.0.tar.gz && \
1062    cd crc32c-1.1.0 && \
1063    cmake \
1064        -DCMAKE_BUILD_TYPE=Release \
1065        -DBUILD_SHARED_LIBS=yes \
1066        -DCRC32C_BUILD_TESTS=OFF \
1067        -DCRC32C_BUILD_BENCHMARKS=OFF \
1068        -DCRC32C_USE_GLOG=OFF \
1069        -H. -Bcmake-out && \
1070    cmake --build cmake-out -- -j ${NCPU:-4} && \
1071sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1072sudo ldconfig
1073```
1074
1075#### nlohmann_json library
1076
1077The project depends on the nlohmann_json library. We use CMake to
1078install it as this installs the necessary CMake configuration files.
1079Note that this is a header-only library, and often installed manually.
1080This leaves your environment without support for CMake pkg-config.
1081
1082```bash
1083cd $HOME/Downloads
1084wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
1085    tar -xzf v3.9.0.tar.gz && \
1086    cd json-3.9.0 && \
1087    cmake \
1088      -DCMAKE_BUILD_TYPE=Release \
1089      -DBUILD_SHARED_LIBS=yes \
1090      -DBUILD_TESTING=OFF \
1091      -H. -Bcmake-out/nlohmann/json && \
1092sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
1093sudo ldconfig
1094```
1095
1096#### Compile and install the main project
1097
1098We can now compile, test, and install `google-cloud-cpp`.
1099
1100```bash
1101cd $HOME/google-cloud-cpp
1102cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
1103cmake --build cmake-out -- -j "${NCPU:-4}"
1104sudo cmake --build cmake-out --target install
1105```
1106
1107
1108### Debian (Stretch)
1109
1110First install the development tools and libcurl.
1111On Debian 9, libcurl links against openssl-1.0.2, and one must link
1112against the same version or risk an inconsistent configuration of the library.
1113This is especially important for multi-threaded applications, as openssl-1.0.2
1114requires explicitly setting locking callbacks. Therefore, to use libcurl one
1115must link against openssl-1.0.2. To do so, we need to install libssl1.0-dev.
1116Note that this removes libssl-dev if you have it installed already, and would
1117prevent you from compiling against openssl-1.1.0.
1118
1119```bash
1120sudo apt-get update && \
1121sudo apt-get --no-install-recommends install -y apt-transport-https apt-utils \
1122        automake build-essential ccache cmake ca-certificates git gcc g++ \
1123        libcurl4-openssl-dev libssl1.0-dev libtool make m4 pkg-config tar wget \
1124        zlib1g-dev
1125```
1126
1127#### Abseil
1128
1129We need a recent version of Abseil.
1130
1131```bash
1132cd $HOME/Downloads
1133wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
1134    tar -xf 20200225.2.tar.gz && \
1135    cd abseil-cpp-20200225.2 && \
1136    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
1137    cmake \
1138      -DCMAKE_BUILD_TYPE=Release \
1139      -DBUILD_TESTING=OFF \
1140      -DBUILD_SHARED_LIBS=yes \
1141      -DCMAKE_CXX_STANDARD=11 \
1142      -H. -Bcmake-out && \
1143    cmake --build cmake-out -- -j ${NCPU:-4} && \
1144sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1145sudo ldconfig
1146```
1147
1148#### Protobuf
1149
1150We need to install a version of Protobuf that is recent enough to support the
1151Google Cloud Platform proto files:
1152
1153```bash
1154cd $HOME/Downloads
1155wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
1156    tar -xf v3.11.3.tar.gz && \
1157    cd protobuf-3.11.3/cmake && \
1158    cmake \
1159        -DCMAKE_BUILD_TYPE=Release \
1160        -DBUILD_SHARED_LIBS=yes \
1161        -Dprotobuf_BUILD_TESTS=OFF \
1162        -H. -Bcmake-out && \
1163    cmake --build cmake-out -- -j ${NCPU:-4} && \
1164sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1165sudo ldconfig
1166```
1167
1168#### c-ares
1169
1170Recent versions of gRPC require c-ares >= 1.13, while Debian Stretch
1171distributes c-ares-1.12. Manually install a newer version:
1172
1173```bash
1174cd $HOME/Downloads
1175wget -q https://github.com/c-ares/c-ares/archive/cares-1_14_0.tar.gz && \
1176    tar -xf cares-1_14_0.tar.gz && \
1177    cd c-ares-cares-1_14_0 && \
1178    ./buildconf && ./configure && make -j ${NCPU:-4} && \
1179sudo make install && \
1180sudo ldconfig
1181```
1182
1183#### gRPC
1184
1185To install gRPC we first need to configure pkg-config to find the version of
1186Protobuf we just installed in `/usr/local`:
1187
1188```bash
1189cd $HOME/Downloads
1190wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
1191    tar -xf v1.29.1.tar.gz && \
1192    cd grpc-1.29.1 && \
1193    cmake \
1194        -DCMAKE_BUILD_TYPE=Release \
1195        -DgRPC_INSTALL=ON \
1196        -DgRPC_BUILD_TESTS=OFF \
1197        -DgRPC_ABSL_PROVIDER=package \
1198        -DgRPC_CARES_PROVIDER=package \
1199        -DgRPC_PROTOBUF_PROVIDER=package \
1200        -DgRPC_SSL_PROVIDER=package \
1201        -DgRPC_ZLIB_PROVIDER=package \
1202        -H. -Bcmake-out && \
1203    cmake --build cmake-out -- -j ${NCPU:-4} && \
1204sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1205sudo ldconfig
1206```
1207
1208#### crc32c
1209
1210The project depends on the Crc32c library, we need to compile this from
1211source:
1212
1213```bash
1214cd $HOME/Downloads
1215wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
1216    tar -xf 1.1.0.tar.gz && \
1217    cd crc32c-1.1.0 && \
1218    cmake \
1219        -DCMAKE_BUILD_TYPE=Release \
1220        -DBUILD_SHARED_LIBS=yes \
1221        -DCRC32C_BUILD_TESTS=OFF \
1222        -DCRC32C_BUILD_BENCHMARKS=OFF \
1223        -DCRC32C_USE_GLOG=OFF \
1224        -H. -Bcmake-out && \
1225    cmake --build cmake-out -- -j ${NCPU:-4} && \
1226sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1227sudo ldconfig
1228```
1229
1230#### nlohmann_json library
1231
1232The project depends on the nlohmann_json library. We use CMake to
1233install it as this installs the necessary CMake configuration files.
1234Note that this is a header-only library, and often installed manually.
1235This leaves your environment without support for CMake pkg-config.
1236
1237```bash
1238cd $HOME/Downloads
1239wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
1240    tar -xzf v3.9.0.tar.gz && \
1241    cd json-3.9.0 && \
1242    sed -i \
1243        -e '1s/VERSION 3.8/VERSION 3.5/' \
1244        -e '/^target_compile_features/d' \
1245        CMakeLists.txt && \
1246    cmake \
1247      -DCMAKE_BUILD_TYPE=Release \
1248      -DBUILD_SHARED_LIBS=yes \
1249      -DBUILD_TESTING=OFF \
1250      -H. -Bcmake-out/nlohmann/json && \
1251sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
1252sudo ldconfig
1253```
1254
1255#### Compile and install the main project
1256
1257We can now compile, test, and install `google-cloud-cpp`.
1258
1259```bash
1260cd $HOME/google-cloud-cpp
1261cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
1262cmake --build cmake-out -- -j "${NCPU:-4}"
1263sudo cmake --build cmake-out --target install
1264```
1265
1266
1267### CentOS (8)
1268
1269Install the minimal development tools, libcurl, OpenSSL, and the c-ares
1270library (required by gRPC):
1271
1272```bash
1273sudo dnf makecache && \
1274sudo dnf install -y epel-release && \
1275sudo dnf makecache && \
1276sudo dnf install -y ccache cmake gcc-c++ git make openssl-devel pkgconfig \
1277        zlib-devel libcurl-devel c-ares-devel tar wget which
1278```
1279
1280The following steps will install libraries and tools in `/usr/local`. By
1281default CentOS-8 does not search for shared libraries in these directories,
1282there are multiple ways to solve this problem, the following steps are one
1283solution:
1284
1285```bash
1286(echo "/usr/local/lib" ; echo "/usr/local/lib64") | \
1287sudo tee /etc/ld.so.conf.d/usrlocal.conf
1288export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
1289export PATH=/usr/local/bin:${PATH}
1290```
1291
1292#### Abseil
1293
1294We need a recent version of Abseil.
1295
1296```bash
1297cd $HOME/Downloads
1298wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
1299    tar -xf 20200225.2.tar.gz && \
1300    cd abseil-cpp-20200225.2 && \
1301    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
1302    cmake \
1303      -DCMAKE_BUILD_TYPE=Release \
1304      -DBUILD_TESTING=OFF \
1305      -DBUILD_SHARED_LIBS=yes \
1306      -DCMAKE_CXX_STANDARD=11 \
1307      -H. -Bcmake-out && \
1308    cmake --build cmake-out -- -j ${NCPU:-4} && \
1309sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1310sudo ldconfig
1311```
1312
1313#### Protobuf
1314
1315We need to install a version of Protobuf that is recent enough to support the
1316Google Cloud Platform proto files:
1317
1318```bash
1319cd $HOME/Downloads
1320wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
1321    tar -xf v3.11.3.tar.gz && \
1322    cd protobuf-3.11.3/cmake && \
1323    cmake \
1324        -DCMAKE_BUILD_TYPE=Release \
1325        -DBUILD_SHARED_LIBS=yes \
1326        -Dprotobuf_BUILD_TESTS=OFF \
1327        -H. -Bcmake-out && \
1328    cmake --build cmake-out -- -j ${NCPU:-4} && \
1329sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1330sudo ldconfig
1331```
1332
1333#### gRPC
1334
1335We also need a version of gRPC that is recent enough to support the Google
1336Cloud Platform proto files. We manually install it using:
1337
1338```bash
1339cd $HOME/Downloads
1340wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
1341    tar -xf v1.29.1.tar.gz && \
1342    cd grpc-1.29.1 && \
1343    cmake \
1344        -DCMAKE_BUILD_TYPE=Release \
1345        -DgRPC_INSTALL=ON \
1346        -DgRPC_BUILD_TESTS=OFF \
1347        -DgRPC_ABSL_PROVIDER=package \
1348        -DgRPC_CARES_PROVIDER=package \
1349        -DgRPC_PROTOBUF_PROVIDER=package \
1350        -DgRPC_SSL_PROVIDER=package \
1351        -DgRPC_ZLIB_PROVIDER=package \
1352        -H. -Bcmake-out && \
1353    cmake --build cmake-out -- -j ${NCPU:-4} && \
1354sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1355sudo ldconfig
1356```
1357
1358#### crc32c
1359
1360The project depends on the Crc32c library, we need to compile this from
1361source:
1362
1363```bash
1364cd $HOME/Downloads
1365wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
1366    tar -xf 1.1.0.tar.gz && \
1367    cd crc32c-1.1.0 && \
1368    cmake \
1369        -DCMAKE_BUILD_TYPE=Release \
1370        -DBUILD_SHARED_LIBS=yes \
1371        -DCRC32C_BUILD_TESTS=OFF \
1372        -DCRC32C_BUILD_BENCHMARKS=OFF \
1373        -DCRC32C_USE_GLOG=OFF \
1374        -H. -Bcmake-out && \
1375    cmake --build cmake-out -- -j ${NCPU:-4} && \
1376sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1377sudo ldconfig
1378```
1379
1380#### nlohmann_json library
1381
1382The project depends on the nlohmann_json library. We use CMake to
1383install it as this installs the necessary CMake configuration files.
1384Note that this is a header-only library, and often installed manually.
1385This leaves your environment without support for CMake pkg-config.
1386
1387```bash
1388cd $HOME/Downloads
1389wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
1390    tar -xzf v3.9.0.tar.gz && \
1391    cd json-3.9.0 && \
1392    cmake \
1393      -DCMAKE_BUILD_TYPE=Release \
1394      -DBUILD_SHARED_LIBS=yes \
1395      -DBUILD_TESTING=OFF \
1396      -H. -Bcmake-out/nlohmann/json && \
1397sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
1398sudo ldconfig
1399```
1400
1401#### Compile and install the main project
1402
1403We can now compile, test, and install `google-cloud-cpp`.
1404
1405```bash
1406cd $HOME/google-cloud-cpp
1407cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
1408cmake --build cmake-out -- -j "${NCPU:-4}"
1409sudo cmake --build cmake-out --target install
1410```
1411
1412
1413### CentOS (7)
1414
1415First install the development tools and OpenSSL. The development tools
1416distributed with CentOS 7 are too old to build the project. In these
1417instructions, we use `cmake3` and `gcc-7` obtained from
1418[Software Collections](https://www.softwarecollections.org/).
1419
1420```bash
1421sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
1422sudo yum install -y centos-release-scl yum-utils
1423sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
1424sudo yum makecache && \
1425sudo yum install -y automake ccache cmake3 curl-devel devtoolset-7 gcc gcc-c++ \
1426        git libtool make openssl-devel pkgconfig tar wget which zlib-devel
1427sudo ln -sf /usr/bin/cmake3 /usr/bin/cmake && sudo ln -sf /usr/bin/ctest3 /usr/bin/ctest
1428```
1429
1430Start a bash shell with its environment configured to use the tools installed
1431by `devtoolset-7`.
1432**IMPORTANT**: All the following commands should be run from this new shell.
1433```bash
1434scl enable devtoolset-7 bash
1435```
1436
1437The following steps will install libraries and tools in `/usr/local`. By
1438default CentOS-7 does not search for shared libraries in these directories,
1439there are multiple ways to solve this problem, the following steps are one
1440solution:
1441
1442```bash
1443(echo "/usr/local/lib" ; echo "/usr/local/lib64") | \
1444sudo tee /etc/ld.so.conf.d/usrlocal.conf
1445export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
1446export PATH=/usr/local/bin:${PATH}
1447```
1448
1449#### Abseil
1450
1451We need a recent version of Abseil.
1452
1453```bash
1454cd $HOME/Downloads
1455wget -q https://github.com/abseil/abseil-cpp/archive/20200225.2.tar.gz && \
1456    tar -xf 20200225.2.tar.gz && \
1457    cd abseil-cpp-20200225.2 && \
1458    sed -i 's/^#define ABSL_OPTION_USE_\(.*\) 2/#define ABSL_OPTION_USE_\1 0/' "absl/base/options.h" && \
1459    cmake \
1460      -DCMAKE_BUILD_TYPE=Release \
1461      -DBUILD_TESTING=OFF \
1462      -DBUILD_SHARED_LIBS=yes \
1463      -DCMAKE_CXX_STANDARD=11 \
1464      -H. -Bcmake-out && \
1465    cmake --build cmake-out -- -j ${NCPU:-4} && \
1466sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1467sudo ldconfig
1468```
1469
1470#### Protobuf
1471
1472We need to install a version of Protobuf that is recent enough to support the
1473Google Cloud Platform proto files:
1474
1475```bash
1476cd $HOME/Downloads
1477wget -q https://github.com/google/protobuf/archive/v3.11.3.tar.gz && \
1478    tar -xf v3.11.3.tar.gz && \
1479    cd protobuf-3.11.3/cmake && \
1480    cmake \
1481        -DCMAKE_BUILD_TYPE=Release \
1482        -DBUILD_SHARED_LIBS=yes \
1483        -Dprotobuf_BUILD_TESTS=OFF \
1484        -H. -Bcmake-out && \
1485    cmake --build cmake-out -- -j ${NCPU:-4} && \
1486sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1487sudo ldconfig
1488```
1489
1490#### c-ares
1491
1492Recent versions of gRPC require c-ares >= 1.11, while CentOS-7
1493distributes c-ares-1.10. Manually install a newer version:
1494
1495```bash
1496cd $HOME/Downloads
1497wget -q https://github.com/c-ares/c-ares/archive/cares-1_14_0.tar.gz && \
1498    tar -xf cares-1_14_0.tar.gz && \
1499    cd c-ares-cares-1_14_0 && \
1500    ./buildconf && ./configure && make -j ${NCPU:-4} && \
1501sudo make install && \
1502sudo ldconfig
1503```
1504
1505#### gRPC
1506
1507We also need a version of gRPC that is recent enough to support the Google
1508Cloud Platform proto files. We manually install it using:
1509
1510```bash
1511cd $HOME/Downloads
1512wget -q https://github.com/grpc/grpc/archive/v1.29.1.tar.gz && \
1513    tar -xf v1.29.1.tar.gz && \
1514    cd grpc-1.29.1 && \
1515    cmake \
1516        -DCMAKE_BUILD_TYPE=Release \
1517        -DgRPC_INSTALL=ON \
1518        -DgRPC_BUILD_TESTS=OFF \
1519        -DgRPC_ABSL_PROVIDER=package \
1520        -DgRPC_CARES_PROVIDER=package \
1521        -DgRPC_PROTOBUF_PROVIDER=package \
1522        -DgRPC_SSL_PROVIDER=package \
1523        -DgRPC_ZLIB_PROVIDER=package \
1524        -H. -Bcmake-out && \
1525    cmake --build cmake-out -- -j ${NCPU:-4} && \
1526sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1527sudo ldconfig
1528```
1529
1530#### crc32c
1531
1532The project depends on the Crc32c library, we need to compile this from
1533source:
1534
1535```bash
1536cd $HOME/Downloads
1537wget -q https://github.com/google/crc32c/archive/1.1.0.tar.gz && \
1538    tar -xf 1.1.0.tar.gz && \
1539    cd crc32c-1.1.0 && \
1540    cmake \
1541        -DCMAKE_BUILD_TYPE=Release \
1542        -DBUILD_SHARED_LIBS=yes \
1543        -DCRC32C_BUILD_TESTS=OFF \
1544        -DCRC32C_BUILD_BENCHMARKS=OFF \
1545        -DCRC32C_USE_GLOG=OFF \
1546        -H. -Bcmake-out && \
1547    cmake --build cmake-out -- -j ${NCPU:-4} && \
1548sudo cmake --build cmake-out --target install -- -j ${NCPU:-4} && \
1549sudo ldconfig
1550```
1551
1552#### nlohmann_json library
1553
1554The project depends on the nlohmann_json library. We use CMake to
1555install it as this installs the necessary CMake configuration files.
1556Note that this is a header-only library, and often installed manually.
1557This leaves your environment without support for CMake pkg-config.
1558
1559```bash
1560cd $HOME/Downloads
1561wget -q https://github.com/nlohmann/json/archive/v3.9.0.tar.gz && \
1562    tar -xzf v3.9.0.tar.gz && \
1563    cd json-3.9.0 && \
1564    cmake \
1565      -DCMAKE_BUILD_TYPE=Release \
1566      -DBUILD_SHARED_LIBS=yes \
1567      -DBUILD_TESTING=OFF \
1568      -H. -Bcmake-out/nlohmann/json && \
1569sudo cmake --build cmake-out/nlohmann/json --target install -- -j ${NCPU} && \
1570sudo ldconfig
1571```
1572
1573#### Compile and install the main project
1574
1575We can now compile, test, and install `google-cloud-cpp`.
1576
1577```bash
1578cd $HOME/google-cloud-cpp
1579cmake -DBUILD_TESTING=OFF -H. -Bcmake-out
1580cmake --build cmake-out -- -j "${NCPU:-4}"
1581sudo cmake --build cmake-out --target install
1582```
1583
1584