Skip to content

CMake problems when compiling SDK as a shared library  #1309

@tete17

Description

@tete17

What platform/OS are you using?

Linux/Docker

Which version of the SDK?

1.7.264

What compiler are you using? what version?

gcc 7.4.0

What are your CMake arguments?

  • BUILD_ONLY="s3"
  • CUSTOM_MEMORY_MANAGEMENT=OFF
  • ENABLE_TESTING=OFF
  • ENABLE_UNITY_BUILD=ON

Can you provide a TRACE level log? (sanitize any sensitive information)

Log output of the CMake consumer project

-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.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
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found AWS SDK for C++, Version: 1.7.264, Install Root:/usr/local, Platform Prefix:, Platform Dependent Libraries: pthread;crypto;ssl;z;curl
-- Components specified for AWSSDK: s3, application wll be depending on libs: aws-cpp-sdk-s3;aws-cpp-sdk-core
-- Try finding aws-cpp-sdk-core
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
CMake Error at /usr/local/lib/aws-c-common/cmake/aws-c-common-config.cmake:7 (include):
  include could not find load file:

    /usr/local/lib/aws-c-common/cmake/static/aws-c-common-targets.cmake
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
  /usr/local/lib/aws-c-event-stream/cmake/aws-c-event-stream-config.cmake:2 (find_dependency)
  /usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
  /usr/local/lib/cmake/aws-cpp-sdk-core/aws-cpp-sdk-core-config.cmake:2 (find_dependency)
  /usr/local/lib/cmake/AWSSDK/AWSSDKConfig.cmake:303 (find_package)
  CMakeLists.txt:6 (find_package)


CMake Error at /usr/local/lib/aws-checksums/cmake/aws-checksums-config.cmake:4 (include):
  include could not find load file:

    /usr/local/lib/aws-checksums/cmake/static/aws-checksums-targets.cmake
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
  /usr/local/lib/aws-c-event-stream/cmake/aws-c-event-stream-config.cmake:3 (find_dependency)
  /usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
  /usr/local/lib/cmake/aws-cpp-sdk-core/aws-cpp-sdk-core-config.cmake:2 (find_dependency)
  /usr/local/lib/cmake/AWSSDK/AWSSDKConfig.cmake:303 (find_package)
  CMakeLists.txt:6 (find_package)


CMake Error at /usr/local/lib/aws-c-event-stream/cmake/aws-c-event-stream-config.cmake:8 (include):
  include could not find load file:

    /usr/local/lib/aws-c-event-stream/cmake/static/aws-c-event-stream-targets.cmake
Call Stack (most recent call first):
  /usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
  /usr/local/lib/cmake/aws-cpp-sdk-core/aws-cpp-sdk-core-config.cmake:2 (find_dependency)
  /usr/local/lib/cmake/AWSSDK/AWSSDKConfig.cmake:303 (find_package)
  CMakeLists.txt:6 (find_package)


-- Found aws-cpp-sdk-core
-- Try finding aws-cpp-sdk-s3
-- Found aws-cpp-sdk-s3
-- Configuring incomplete, errors occurred!
See also "/tmp/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/build/CMakeFiles/CMakeError.log".

Hey Guys. I think I found a problem on the installed cmake files when compiling the library with shared libraries.

Looking at the log output it seems that cmake is not properly communicating to the dependant libraries (i.e. aws-c-common, aws-checksums, etc...) that the installation was done for a shared library.

I have put up a small Docker file for reproducibility purpose

FROM ubuntu:18.04

RUN apt-get update \
        && apt-get install -y \
                ca-certificates \
                curl \
                build-essential \
                curl \
                git \
                cmake \
                libz-dev \
                libssl-dev \
                libcurl4-openssl-dev


RUN git clone --depth 1 --shallow-submodules --branch 1.7.264 https://github.com/aws/aws-sdk-cpp.git \
        && mkdir aws-obj \
        && (cd aws-obj \
                && cmake \
                        -DBUILD_ONLY="s3" \
                        -DCUSTOM_MEMORY_MANAGEMENT=OFF \
                        -DENABLE_TESTING=OFF \
                        -DENABLE_UNITY_BUILD=ON \
                        ../aws-sdk-cpp \
                && make -j$(nproc) install) \
        && rm -r aws-obj aws-sdk-cpp

WORKDIR /tmp
COPY . /tmp/

RUN mkdir build && cd build \
    && cmake .. \

The CMakeLists.txt file looks like this

cmake_minimum_required(VERSION 3.10)
project(aws_bug)

set(CMAKE_CXX_STANDARD 14)

find_package(AWSSDK REQUIRED COMPONENTS s3)

add_executable(aws_bug main.cpp)

Digging through the Cmake files I found that this is communicated with the Cmake variable BUILD_SHARED_LIBS to "ON". Applying this variable to the project seemed to fix the issue as a workaround but i believe is not the intended behaviour. Let me know if you need more input from me

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeIssue requires a breaking change to remediate.dependenciesThis issue is a problem in a dependency.guidanceQuestion that needs advice or information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions