AWS SDK C++ install using cmake on Ubuntu, problem with installing third-party libraries

Viewed 1994

I am installing the aws-cpp-sdk in Ubuntu 20.04 by following the installation instructions on: https://github.com/aws/aws-sdk-cpp

I built/installed the SDK from source as per the instructions which worked. Installation locations:

  • /usr/local/lib
  • /usr/local/include/aws

I built/installed the aws-c-common as per the instructions (although I didn't use a DCMAKE_INSTALL_PREFIX).

I attempt to build aws-checksums but can't get past the cmake. When I run cmake .. while in the build directory which is in the code directory I get:

-- The C compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
/usr/local/lib/cmake/lib/cmake
CMake Error at CMakeLists.txt:32 (include):
  include could not find load file:

    AwsCFlags

CMake Error at CMakeLists.txt:33 (include):
  include could not find load file:

    AwsCheckHeaders

CMake Error at CMakeLists.txt:34 (include):
  include could not find load file:

    AwsSharedLibSetup

CMake Error at CMakeLists.txt:35 (include):
  include could not find load file:

    AwsSanitizers

CMake Error at CMakeLists.txt:37 (include):
  include could not find load file:

    AwsFindPackage

CMake Error at CMakeLists.txt:38 (include):
  include could not find load file:

    AwsFeatureTests

CMake Error at CMakeLists.txt:116 (aws_set_common_properties):
  Unknown CMake command "aws_set_common_properties".

-- Configuring incomplete, errors occurred!
See also ...

I've tried to point the prefix to the sdk install folders but that did not solve my problem. That is where I get stuck. Any input is appreciated. Thank you.

3 Answers

If you are building from source make sure to use this command

git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp

I ran into a similar issue while building because I was missing the --recurse-submodules tag. I built inside a docker container running Ubuntu. My solution is for the AWS cpp sdk, but it might also work for your case.

I do this inside a Dockerfile, and it runs properly:

RUN cd /tmp \
  && git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp.git \
  && cd aws-sdk-cpp \
  && mkdir build \
  && cd build \
  && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="ecr" \
  && make \
  && make install

It builds without the -DBUILD_ONLY option as well. However, this is on Ubuntu 18.04 LTS, not 20.04. I don't imagine there's a difference, however.

You haven't said what options you're feeding cmake.

I've created a demo application s3-demo that gets the list of buckets in a specific region. This project is available at github.com/unfor19/docker-aws-sdk-cpp

I also had the same issue that you had (and many more), but I was finally able to cook a Dockerfile that builds aws-sdk-cpp and the demo application.

Here's my Dockerfile

ARG AWS_SDK_CPP_VERSION="1.8.160"
ARG AWS_SDK_CPP_BUILD_TYPE="Release"
ARG APP_BUILD_TYPE="Release"

### -----------------------------------------------------
### Base image
### -----------------------------------------------------
FROM ubuntu:20.04 as base

# Fix tzdata hang
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN \
    apt-get update && \
    apt-get install -y \
    curl wget git zip unzip \
    cmake g++ gcc \
    libcurl4-openssl-dev libssl-dev libpulse-dev \
    uuid-dev zlib1g-dev

RUN apt-get update && \
    apt-get install -y \
    make golang-1.13

ENV PATH="$PATH:/usr/lib/go-1.13/bin"
COPY scripts/ /usr/local/bin/
WORKDIR /code/


### -----------------------------------------------------
### Build aws-sdk-cpp
### -----------------------------------------------------
FROM base as build-aws-sdk-cpp
ARG AWS_SDK_CPP_VERSION
ARG AWS_SDK_CPP_BUILD_TYPE
ENV AWS_SDK_CPP_VERSION="${AWS_SDK_CPP_VERSION}" \
    AWS_SDK_CPP_BUILD_TYPE="${AWS_SDK_CPP_BUILD_TYPE}"
WORKDIR /code/
RUN download.sh "https://github.com/aws/aws-sdk-cpp/archive/${AWS_SDK_CPP_VERSION}.zip"
WORKDIR /sdk_build/
RUN cmake /code/aws-sdk-cpp-${AWS_SDK_CPP_VERSION} -DBUILD_ONLY="s3" -DCMAKE_BUILD_TYPE="${AWS_SDK_CPP_BUILD_TYPE}"
RUN make && \
    make install && \
    rm -rf /code/


### -----------------------------------------------------
### Build the application
### -----------------------------------------------------
FROM build-aws-sdk-cpp as build-app
WORKDIR /code/
COPY . .
ARG APP_BUILD_TYPE
ENV APP_BUILD_TYPE="${APP_BUILD_TYPE}"
RUN rm -rf build && cmake -S . -B build -DCMAKE_BUILD_TYPE="${APP_BUILD_TYPE}"
WORKDIR /code/build/
RUN make
# Default region N.Virginia
Related