AWS SDK for C++
Developer Guide

Setting Up the AWS SDK for C++

This section presents information about how to set up the AWS SDK for C++ on your development platform.

Prerequisites

To use the AWS SDK for C++, you need:

  • Visual Studio 2013 or later

    Note

    Visual Studio 2013 doesn't provide default move constructors and operators. Later versions of Visual Studio provide a standards-compliant compiler.

  • or GNU Compiler Collection (GCC) 4.9 or later

  • or Clang 3.3 or later

  • A minimum of 4 GB of RAM

    Note

    You need 4 GB of RAM to build some of the larger AWS clients. The SDK might fail to build on Amazon EC2 instance types t2.micro, t2.small, and other small instance types due to insufficient memory.

Additional Requirements for Linux Systems

To compile on Linux, you must have the header files (-dev packages) for libcurl, libopenssl, libuuid, zlib, and, optionally, libpulse for Amazon Polly support. The packages are typically found by using the system's package manager.

To install the packages on Debian/Ubuntu-based systems

sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev libpulse-dev

To install the packages on Redhat/Fedora-based systems

sudo dnf install libcurl-devel openssl-devel libuuid-devel pulseaudio-devel

To install the packages on CentOS-based systems

sudo yum install libcurl-devel openssl-devel libuuid-devel pulseaudio-libs-devel

Getting the SDK Using NuGet with Visual C++

You can use NuGet to manage dependencies for AWS SDK for C++ projects that you develop with Microsoft Visual C++. To use this procedure, you must have NuGet installed on your system.

To use the SDK with NuGet

  1. Open your project in Visual Studio.

  2. In Solution Explorer, right-click your project name, and then choose Manage NuGet Packages.

  3. Select the packages to use by searching for a particular service or library name. For example, you could use a search term such as aws s3 native. Or, because AWS SDK for C++ libraries are named consistently, use AWSSDKCPP-service name to add a library for a particular service to your project.

  4. Choose Install to install the libraries and add them to your project.

When you build your project, the correct binaries are automatically included for each runtime/architecture configuration you use—you won't need to manage these dependencies yourself.

Getting the SDK Using Vcpkg with Visual C++

You can use vcpkg to manage dependencies for AWS SDK for C++ projects that you develop with Microsoft Visual C++. To use this procedure, you must have vcpkg installed on your system.

To use the SDK with vcpkg

  1. Open a Windows command prompt and navigate to the vcpkg directory.

  2. Integrate vcpkg into Visual Studio. You can integrate per project or per user. The command line shown below integrates vcpkg for the current user.

    vcpkg integrate install
  3. Install the AWS SDK for C++ package. The package compiles the entire SDK and its dependencies. It can take a while.

    vcpkg install aws-sdk-cpp[*]:x86-windows --recurse

    To reduce build time, build only the SDK packages needed. Specify the package names in square brackets. Also include the SDK core package.

    vcpkg install aws-sdk-cpp[core,s3,ec2]:x86-windows

    A package name can be derived from the AWS SDK for C++ repo directory name for the service.

    aws-sdk-cpp\aws-cpp-sdk-<packageName> # Repo directory name and packageName aws-sdk-cpp\aws-cpp-sdk-s3 # Example: Package name is s3
  4. Open your project in Visual Studio.

  5. #include the AWS SDK for C++ header files you want in your source code.

Like NuGet, when you build your project, the correct binaries are automatically included for each runtime/architecture configuration you use.

Building the SDK from Source

If you don't use Visual Studio (or don't want to use NuGet), you can build the SDK from source to set it up for your development system. This method also enables you to customize your SDK build—see CMake Parameters for the available options.

To build the SDK from source

  1. Download or clone the SDK source from aws/aws-sdk-cpp on GitHub.

    • Direct download: aws/aws-sdk-cpp/archive/master.zip

    • Clone with Git:

      HTTPSSSH
      HTTPS
      git clone https://github.com/aws/aws-sdk-cpp.git
      SSH
      git clone git@github.com:aws/aws-sdk-cpp.git
  2. Install cmake (v3.2 or later) and the relevant build tools for your platform. Ensure they are available in your PATH.

  3. Create a directory in which to store your buildfiles. Then generate the buildfiles by running cmake . This is the recommended approach, referred to as an out-of-source build.

    sudo mkdir sdk_build cd sdk_build sudo cmake <path/to/sdk/source>

    Alternatively, create the build files directly in the SDK source directory.

    cd <path/to/sdk/source> sudo cmake .

    Building the entire SDK can take a while. To build only a particular client, such as Amazon S3, you can use the cmake BUILD_ONLY parameter demonstrated below. For more ways to modify the build output, see CMake Parameters.

    sudo cmake -DBUILD_ONLY="s3"
  4. Build the SDK by running one of the following operating system-dependent commands. If you're building the entire SDK, the operation can take three hours or longer.

    auto make (Linux/macOS)Visual Studio (Windows)
    auto make (Linux/macOS)
    sudo make
    Visual Studio (Windows)
    msbuild ALL_BUILD.vcxproj
  5. Install the SDK by running one of the following operating system-dependent commands.

    auto make (Linux/macOS)Visual Studio (Windows)
    auto make (Linux/macOS)
    sudo make install
    Visual Studio (Windows)
    // Run this command in a command shell running in ADMIN mode // The SDK is installed in `\Program Files (x86)\aws-cpp-sdk-all\` msbuild INSTALL.vcxproj

Building for Android

To build for Android, add -DTARGET_ARCH=ANDROID to your cmake command line. The AWS SDK for C++ includes a cmake toolchain file that should cover what's needed, assuming you've set the appropriate environment variables (ANDROID_NDK).

Android on Windows

Building for Android on Windows requires additional setup. In particular, you have to run cmake from a Visual Studio (2013 or later) developer command prompt. You'll also need the commands git and patch in your path. If you have git installed on a Windows system, you'll most likely find patch in a sibling directory (.../Git/usr/bin/). Once you've verified these requirements, your cmake command line will change slightly to use nmake .:

cmake -G "NMake Makefiles" `-DTARGET_ARCH=ANDROID` <other options> ..

nmake builds targets in serially. To make things go more quickly, we recommend installing JOM as an alternative to nmake , and then changing the cmake invocation as follows.:

cmake -G "NMake Makefiles JOM" `-DTARGET_ARCH=ANDROID` <other options> ..

Creating Release Builds

auto makeVisual Studio
auto make
cmake -DCMAKE_BUILD_TYPE=Release <path/to/sdk/source> make sudo make install
Visual Studio
cmake <path-to-root-of-this-source-code> -G "Visual Studio 12 Win64" msbuild INSTALL.vcxproj /p:Configuration=Release

Running Integration Tests

Several directory names include the suffix *integration-tests. After the project is built, the tests stored in these directories can be run to verify the project's correct execution.