This repository contains common types and functions used by the Google Cloud C++ Client Libraries.
The Google Cloud C++ libraries are tested with the following compilers:
Compiler | Minimum Version |
---|---|
GCC | 4.8 |
Clang | 3.8 |
MSVC++ | 14.1 |
Apple Clang | 8.1 |
The Google Cloud C++ Client Libraries can be built with CMake or Bazel. The minimal versions of these tools we test with are:
Tool | Minimum Version |
---|---|
CMake | 3.5 |
Bazel | 0.24.0 |
The libraries also depend on gRPC, libcurl, and the dependencies of those libraries. The Google Cloud C++ Client libraries are tested with the following versions of these dependencies:
Library | Minimum version |
---|---|
gRPC | v1.16.x |
libcurl | 7.47.0 |
Integration tests at times use the Google Cloud SDK. The integration tests run against the latest version of the SDK on each commit and PR.
Install the development tools needed to compile the project:
sudo dnf makecache && \
sudo dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \
zlib-devel
The development tools distributed with CentOS (notably CMake) are too old to
build google-cloud-cpp
. In these instructions, we use cmake3
obtained from
Software Collections.
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install -y centos-release-scl
sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
sudo yum makecache && \
sudo yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \
make openssl-devel pkgconfig tar wget which zlib-devel
ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest
sudo apt update && \
sudo apt install -y build-essential cmake git gcc g++ cmake \
libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev make \
pkg-config tar wget zlib1g-dev
On Debian Stretch, libcurl links against openssl-1.0.2, and one must link against the same version or risk an inconsistent configuration of the library. This is especially important for multi-threaded applications, as openssl-1.0.2 requires explicitly setting locking callbacks. Therefore, to use libcurl one must link against openssl-1.0.2. To do so, we need to install libssl1.0-dev. Note that this removes libssl-dev if you have it installed already, and would prevent you from compiling against openssl-1.1.0.
sudo apt update && \
sudo apt install -y build-essential cmake git gcc g++ cmake \
libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl1.0-dev make \
pkg-config tar wget zlib1g-dev
sudo dnf makecache && \
sudo dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \
zlib-devel
sudo zypper refresh && \
sudo zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \
libcurl-devel libopenssl-devel make tar wget zlib-devel
sudo zypper refresh && \
sudo zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \
libcurl-devel libopenssl-devel make tar wget
sudo apt update && \
sudo apt install -y build-essential cmake git gcc g++ cmake \
libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev make \
pkg-config tar wget zlib1g-dev
sudo apt update && \
sudo apt install -y build-essential cmake git gcc g++ cmake \
libcurl4-openssl-dev libssl-dev make \
pkg-config tar wget zlib1g-dev
We use the ubuntu-toolchain-r
PPA to get a modern version of CMake:
sudo apt update && sudo apt install -y software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt update && \
sudo apt install -y cmake3 git gcc g++ make pkg-config tar wget \
zlib1g-dev
Ubuntu:14.04 ships with a very old version of OpenSSL, this version is not supported by gRPC. We need to compile and install OpenSSL-1.0.2 from source.
cd $HOME/Downloads
wget -q https://www.openssl.org/source/openssl-1.0.2n.tar.gz
tar xf openssl-1.0.2n.tar.gz
cd $HOME/Downloads/openssl-1.0.2n
./config --shared
make -j ${NCPU:-4}
sudo make install
Note that by default OpenSSL installs itself in /usr/local/ssl
. Installing
on a more conventional location, such as /usr/local
or /usr
, can break
many programs in your system. OpenSSL 1.0.2 is actually incompatible with
with OpenSSL 1.0.0 which is the version expected by the programs already
installed by Ubuntu 14.04.
In any case, as the library installs itself in this non-standard location, we also need to configure CMake and other build program to find this version of OpenSSL:
export OPENSSL_ROOT_DIR=/usr/local/ssl
export PKG_CONFIG_PATH=/usr/local/ssl/lib/pkgconfig
brew install curl cmake libressl c-ares
If you are already using vcpkg, a package manager from Microsoft,
you can download and compile google-cloud-cpp
in a single step:
.\vcpkg.exe install google-cloud-cpp:x64-windows-static
This command will also print out instructions on how to use the library from
your MSBuild or CMake-based projects. We try to keep the version of
google-cloud-cpp
included with vcpkg
up-to-date, our practice is to submit a
PR to update the version in vcpkg
after each release of google-cloud-cpp
.
See below for instructions to compile the code yourself.
To build all available libraries and run the tests, run the following commands after cloning this repo:
To automatically download the dependencies and compile the libraries and examples you can use the CMake super build:
# Add -DBUILD_TESTING=OFF to disable tests
cmake -Hsuper -Bcmake-out
# Adjust the number of threads used by modifying parameter for `-j 4`
# following command will also invoke ctest at the end
cmake --build cmake-out -- -j 4
You will find compiled binaries in cmake-out/
respective to their source
paths.
If you prefer to compile against installed versions of the dependencies please check the INSTALL.md file.
If you prefer to install dependencies at a custom location and want to compile against it, please check the instruction at build with CMake.
export OPENSSL_ROOT_DIR=/usr/local/opt/libressl
# Add -DBUILD_TESTING=OFF to disable tests
cmake -Hsuper -Bcmake-out
# Adjust the number of threads used by modifying parameter for `-j 4`
cmake --build cmake-out -- -j 4
# Verify build by running tests
(cd cmake-out && ctest --output-on-failure)
You will find compiled binaries in cmake-out/
respective to their source paths.
You will find compiled binaries in cmake-out/
respective to their source
paths.
If you prefer to compile against installed versions of the dependencies please check the INSTALL.md file.
If you see the following error:
CMake Error in google/cloud/storage/CMakeLists.txt:
Imported target "CURL::libcurl" includes non-existent path
"/usr/include"
you need to update your Xcode version.
Install the package located at
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
and run:
xcode-select -s /Library/Developer/CommandLineTools
If you prefer to manually compile on Windows the following instructions should work, though there is a lot more variability on this platform. We welcome suggestions to make this an easier process.
We will assume that you have installed CMake, Ninja, and "Microsoft Visual Studio 2017". If you have not, install Chocolatey using this command as the administrator:
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command ^
"iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Then you can easily install the necessary development tools.
choco install -y cmake cmake.portable ninja visualstudio2017community
choco install -y visualstudio2017-workload-nativedesktop
choco install -y microsoft-build-tools
choco install -y git
Then clone and compile vcpkg
:
set SOURCE="%cd%"
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
Use vcpkg
to download and install google-cloud-cpp
's dependencies:
.\vcpkg.exe install openssl:x64-windows-static ^
grpc:x64-windows-static ^
curl:x64-windows-static ^
gtest:x64-windows-static ^
googleapis:x64-windows-static ^
crc32c:x64-windows-static
.\vcpkg.exe integrate install
Now clone google-cloud-cpp
:
cd ..
git clone https://github.com/googleapis/google-cloud-cpp.git
cd google-cloud-cpp
Load the environment variables needed to use Microsoft Visual Studio:
call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
Use CMake to create the build files:
cmake -H. -Bcmake-out -GNinja ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_TOOLCHAIN_FILE="%SOURCE%\vcpkg\scripts\buildsystems\vcpkg.cmake" ^
-DVCPKG_TARGET_TRIPLET=x64-windows-static ^
-DCMAKE_C_COMPILER=cl.exe ^
-DCMAKE_CXX_COMPILER=cl.exe ^
-DCMAKE_MAKE_PROGRAM=ninja
And compile the code:
cmake --build cmake-out
Finally, verify the unit tests pass:
cd cmake-out
ctest --output-on-failure
You will find compiled binaries in cmake-out\
respective to their
source directories.
By default google-cloud-cpp
downloads and compiles all its dependencies.
The default configuration disables the install
target, because the version of
the dependencies downloaded by google-cloud-cpp
may conflict with the versions
already installed in your system, or with the versions you want to use for
development.
To install google-cloud-cpp
you must first install all its dependencies. Then
you must configure google-cloud-cpp
to find these dependencies, and install
it.
Installing the dependencies themselves may be as simple as using the package
manager for your platform, or may require manually downloading, compiling, and
installing said dependencies. The INSTALL.md file describes how
to successfully install google-cloud-cpp
on several platforms.
Alternatively, if you prefer to use google-cloud-cpp
as a submodule, you can
use the CMake command
add_subdirectory()
to include google-cloud-cpp
directly in your CMake project.
Please note that the Google Cloud C++ client libraries do not follow Semantic Versioning.
GA: Libraries defined at a GA quality level are expected to be stable and any backwards-incompatible changes will be noted in the documentation. Major changes to the API will signaled by changing major version number (e.g. 1.x.y -> 2.0.0).
Beta: Libraries defined at a Beta quality level are expected to be mostly stable and we're working towards their release candidate. We will address issues and requests with a higher priority.
Alpha: Libraries defined at an Alpha quality level are still a work-in-progress and are more likely to get backwards-incompatible updates. Additionally, it's possible for Alpha libraries to get deprecated and deleted before ever being promoted to Beta or GA.
See CONTRIBUTING.md
for details on how to contribute to
this project, including how to build and test your changes as well as how to
properly format your code.
Apache 2.0; see LICENSE
for details.