Build the AWS SDK for C++ on Linux/macOS
To set up the AWS SDK for C++, you can either build the SDK yourself directly from the source or download the libraries using a package manager.
The SDK source is separated into individual packages by service. Installing the entire SDK can take up to an hour. Installing only the specific subset of
services that your program uses decreases installation time and also reduces size on disk. To choose which services to install, you need to know the package name
of each service your program uses. You can see the list of package directories at aws/aws-sdk-cpp
aws-sdk-cpp\aws-cpp-sdk-
<packageName>
# Repo directory name and packageName aws-sdk-cpp\aws-cpp-sdk-s3 # Example: Package name is s3
Prerequisites
You need a minimum of 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.
To use the AWS SDK for C++, you need one of the following:
-
GNU Compiler Collection (GCC) 4.9 or later, or
-
Clang 3.3 or later.
Additional Requirements for Linux Systems
You must have the header files (-dev
packages) for libcurl
, libopenssl
, libuuid
,
zlib
, and, optionally, libpulse
for Amazon Polly support. You can find the packages by using your 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 Amazon Linux/Redhat/Fedora/CentOS-based systems
-
sudo yum install libcurl-devel openssl-devel libuuid-devel pulseaudio-libs-devel
Building the SDK from Source
You can build the SDK from source using command-line tools as an alternative to using vcpkg. Using this method, you can customize your SDK build. For information about available options, see CMake Parameters.
To build the SDK from source
-
Install CMake
(minimum version 3.13) and the relevant build tools for your platform. It is recommended to add cmake
to yourPATH
. To check your version of CMake, open a command prompt and run commandcmake --version
-
In a command prompt, navigate to a folder where you want to store the SDK.
-
Get the latest source code.
Version 1.11 uses git submodules to wrap external dependencies. This includes the CRT libraries described in the AWS SDKs and Tools Reference Guide.
Download or clone the SDK source from
aws/aws-sdk-cpp
on GitHub: -
Clone with Git: HTTPS
git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
-
Clone with Git: SSH
git clone --recurse-submodules git@github.com:aws/aws-sdk-cpp.git
-
-
We recommend you store the generated build files outside of the SDK source directory. Create a new directory to store the build files in and navigate to that folder.
mkdir
sdk_build
cdsdk_build
-
Generate the build files by running
cmake
. Specify on thecmake
command line whether to build a Debug or Release version. ChooseDebug
throughout this procedure to run a debug configuration of your application code. ChooseRelease
throughout this procedure to run a release configuration of your application code. Command syntax:{path to cmake if not in PATH} {path to source location of aws-sdk-cpp} -DCMAKE_BUILD_TYPE=[Debug | Release] -DCMAKE_PREFIX_PATH={path to install} -DCMAKE_INSTALL_PREFIX={path to install}
For more ways to modify the build output, see CMake Parameters.
Note
When building on a Mac with a case-insensitive filesystem, check the output of the
pwd
command in the directory where you run the build. Make sure that thepwd
output uses mixed case for directory names such as/Users
andDocuments
.To generate the build files, do one of the following:
-
Generate build files (all AWS services): To build the entire SDK, run cmake, specifying whether to build a Debug or Release version. For example:
cmake
../aws-sdk-cpp
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_PREFIX_PATH=/usr/local/
-DCMAKE_INSTALL_PREFIX=/usr/local/
-
Generate build files (subset AWS services): To build only a particular service or services package(s) for the SDK, add the CMake BUILD_ONLY parameter, with the service names separated by semicolons. The following example builds only the Amazon S3 service package:
cmake
../aws-sdk-cpp
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_PREFIX_PATH=/usr/local/
-DCMAKE_INSTALL_PREFIX=/usr/local/
-DBUILD_ONLY="s3
"
Note
If you get an error
Failed to build third-party libraries
, check your version of CMake by runningcmake --version
. You must use CMake minimum version 3.13. -
-
Build the SDK binaries. If you’re building the entire SDK, the operation can take one hour or longer.
make
-
Install the SDK. You may need to escalate privileges depending on the location you chose to install to.
make install
Building for Android on Linux
To build for Android, add -DTARGET_ARCH=ANDROID
to your cmake
command line. The AWS SDK for C++ includes a CMake toolchain file that includes what you need by
referencing the appropriate environment variables (ANDROID_NDK
). For an
example application, see Setting up an Android application with AWS SDK for C++