Building

The C/C++ driver will build on most standard Unix-like and Microsoft Windows platforms. Packages are available for the following platforms:

NOTE: The build procedures only need to be performed for driver development or if your system doesn’t have packages available for download and installation.

Compatibility

  • Architectures: 32-bit (x86) and 64-bit (x64)
  • Compilers: GCC 4.1.2+ Clang 3.4+, and MSVC 2010/2012/2013/2015/2017

Dependencies

The C/C++ driver depends on the following software:

Linux/Mac OS

The driver is known to build on CentOS/RHEL 6/7, Mac OS X 10.10/10.11 (Yosemite and El Capitan), Mac OS 10.12 (Sierra), and Ubuntu 14.04/16.04 LTS.

NOTE: The driver will also build on most standard Unix-like systems using GCC 4.1.2+ or Clang 3.4+.

Installing dependencies

Initial environment setup

CentOS/RHEL (Yum)
yum install automake cmake gcc-c++ git libtool
Ubuntu (APT)
apt-get update
apt-get install build-essential cmake git
Mac OS (Brew)

Homebrew (or brew) is a free and open-source software package management system that simplifies the installation of software on the Mac OS operating system. Ensure Homebrew is installed before proceeding.

brew update
brew upgrade
brew install autoconf automake cmake libtool

libuv

libuv v1.x should be used in order to ensure all features of the C/C++ driver are available. When using a package manager for your operating system make sure you install v1.x; if available.

CentOS/RHEL and Ubuntu packages

Packages are available from our download server:

Mac OS (Brew)
brew install libuv
Manually build and install

The following procedures should be performed if packages are not available for your system.

pushd /tmp
wget http://dist.libuv.org/dist/v1.14.0/libuv-v1.14.0.tar.gz
tar xzf libuv-v1.14.0.tar.gz
pushd libuv-v1.14.0
sh autogen.sh
./configure
make install
popd
popd

OpenSSL

The DataStax C/C++ driver requires OpenSSL v1.0.x; v1.1.x+ is not currently supported by the driver. Ensure that you are installing and using a compatible version of OpenSSL.

CentOS (Yum)
yum install openssl-devel
Ubuntu (APT)
apt-get install libssl-dev
Mac OS (Brew)
brew install openssl

Note: For Mac OS X 10.11 (El Capitan) and Mac OS 10.12 (Sierra) a link needs to be created in order to make OpenSSL available to the building libraries:

brew link --force openssl
Manually build and install
pushd /tmp
wget --no-check-certificate https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar xzf openssl-1.0.2l.tar.gz
pushd openssl-1.0.2l
CFLAGS=-fpic ./config shared
make
make install
popd
popd

Building and installing the C/C++ driver

mkdir build
pushd build
cmake ..
make
make install
popd

Building examples (optional)

Examples are not built by default and need to be enabled. Update your CMake line to build examples.

cmake -DCASS_BUILD_EXAMPLES=On ..

Building tests (optional)

Tests (integration and unit) are not built by default and need to be enabled. Before proceeding Boost v1.59.0+ must be installed to properly configure and build the integration and unit tests.

Once Boost is installed, update your CMake line to build tests.

Boost
CentOS/RHEL and Ubuntu

CentOS/RHEL and Ubuntu do not contain Boost v1.59+ libraries in its repositories; however the following steps will install Boost from source:

Note: Ensure previous version of Boost has been removed before proceeding.

pushd /tmp
wget http://sourceforge.net/projects/boost/files/boost/1.64.0/boost_1_64_0.tar.gz/download -O boost_1_64_0.tar.gz
tar xzf boost_1_64_0.tar.gz
pushd boost_1_64_0
./bootstrap.sh --with-libraries=atomic,chrono,system,thread,test
sudo ./b2 cxxflags="-fPIC" install
popd
popd
Mac OS
brew install boost
Integration tests
cmake -DCASS_BUILD_INTEGRATION_TESTS=On ..
Unit tests
cmake -DCASS_BUILD_UNIT_TESTS=On ..

Windows

We provide a self-contained batch script for building the C/C++ driver and all of its dependencies. In order to run it, you have to install the build dependencies and clone the repository with the DataStax C/C++ driver for DataStax Enterprise.

Obtaining build dependencies

  • Download and install Bison
    • Make sure Bison is in your system PATH and not installed in a directory with spaces (e.g. %SYSTEMDRIVE%\GnuWin32)
  • Download and install CMake
    • Make sure to select the option “Add CMake to the system PATH for all users” or “Add CMake to the system PATH for current user”
  • Download and install Git
    • Make sure to select the option “Use Git from Windows Command Prompt” or manually add the git executable to the system PATH.
  • Download and install ActiveState Perl
    • Make sure to select the option “Add Perl to PATH environment variable”
  • Download and install Python v2.7.x
    • Make sure to select/install the feature “Add python.exe to Path”
  • Download and install Boost (Optional: Tests only)

Building the driver

The batch script detects installed versions of Visual Studio to simplify the build process on Windows and select the correct version of Visual Studio when compiling the driver.

First you will need to open a “Command Prompt” to execute the batch script. Running the batch script without any arguments will build the driver for C/C++ driver for the current system architecture (e.g. x64).

To perform advanced build configuration, execute the batch script with the --HELP argument to display the options available.

Usage: VC_BUILD.BAT [OPTION...]

    --DEBUG                           Enable debug build
    --RELEASE                         Enable release build (default)
    --DISABLE-CLEAN                   Disable clean build
    --DEPENDENCIES-ONLY               Build dependencies only
    --TARGET-COMPILER [version]       141, 140, 120, 110, or 100
    --DISABLE-OPENSSL                 Disable OpenSSL support
    --ENABLE-EXAMPLES                 Enable example builds
    --ENABLE-PACKAGES [version]       Enable package generation (*)
    --ENABLE-ZLIB                     Enable zlib
    --GENERATE-SOLUTION               Generate Visual Studio solution (**)
    --INSTALL-DIR [install-dir]       Override installation directory
    --SHARED                          Build shared library (default)
    --STATIC                          Build static library
    --ENABLE-SHARED-OPENSSL           Force shared OpenSSL library
    --X86                             Target 32-bit build (***)
    --X64                             Target 64-bit build (***)
    --USE-BOOST-ATOMIC                Use Boost atomic

    Testing Arguments

    --ENABLE-TESTS
         [boost-root-dir]             Enable integration and unit tests build
    --ENABLE-INTEGRATION-TESTS
         [boost-root-dir]             Enable integration tests build
    --ENABLE-UNIT-TESTS
         [boost-root-dir]             Enable unit tests build
    --ENABLE-LIBSSH2                  Enable libssh2 (remote server testing)

    --HELP                            Display this message

*   Packages are only generated using detected installations of Visual Studio
**  Dependencies are built before generation of Visual Studio solution
*** Default target architecture is determined based on system architecture

Note: When overriding installation directory using --INSTALL-DIR, the driver dependencies will also be copied (e.g. C:\myproject\dependencies\libs)