Skip to content

Errors building a hello world example using C++ SDK on OSX #1334

@dblock

Description

@dblock

How do I build a basic hello world example?

What platform/OS are you using?

MacOS Mojave

Which version of the SDK?

1.7.278

What compiler are you using? what version?

cmake version 3.16.4
GNU Make 3.81

Building the SDK

Downloading and building SDK works.

git clone git@github.com:aws/aws-sdk-cpp.git
cd aws-sdk-cpp
git checkout '1.7.278'
mkdir build & cd build
cmake ../ -D CMAKE_BUILD_TYPE=Debug
make

Scanning dependencies of target aws-cpp-sdk-core
... a few hours later
Scanning dependencies of target polly_sample
[100%] Building CXX object aws-cpp-sdk-polly-sample/CMakeFiles/polly_sample.dir/main.cpp.o
[100%] Linking CXX executable polly_sample
[100%] Built target polly_sample

List S3 Buckets Sample

Trying to follow this doc or this blog post.

mkdir list-s3-buckets & cd list-s3-buckets

main.cpp

#include <iostream>
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/Bucket.h>

int main(int argc, char** argv)
{
    Aws::SDKOptions options;
    Aws::InitAPI(options);

    // more code here

    Aws::ShutdownAPI(options);
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(s3-sample)

find_package(aws-sdk-cpp)

add_executable(s3-sample main.cpp)

target_link_libraries(s3-sample aws-cpp-sdk-s3)

Reading https://aws.amazon.com/blogs/developer/using-cmake-exports-with-the-aws-sdk-for-c/ I run into missing dependencies, similar to #406.

osx ~/source/aws-sdk/list-s3-buckets/build$ cmake -Daws-sdk-cpp_DIR=/Users/dblock/source/aws-sdk/aws-sdk-cpp/build ..
-- The C compiler identification is AppleClang 11.0.0.11000020
-- The CXX compiler identification is AppleClang 11.0.0.11000020
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/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: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at /usr/local/Cellar/cmake/3.16.4/share/cmake/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
  By not providing "Findaws-c-event-stream.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "aws-c-event-stream", but CMake did not find one.

  Could not find a package configuration file provided by
  "aws-c-event-stream" with any of the following names:

    aws-c-event-streamConfig.cmake
    aws-c-event-stream-config.cmake

  Add the installation prefix of "aws-c-event-stream" to CMAKE_PREFIX_PATH or
  set "aws-c-event-stream_DIR" to a directory containing one of the above
  files.  If "aws-c-event-stream" provides a separate development package or
  SDK, be sure it has been installed.
Call Stack (most recent call first):
  /Users/dblock/source/aws-sdk/aws-sdk-cpp/build/aws-cpp-sdk-core/aws-cpp-sdk-core-config.cmake:2 (find_dependency)
  /Users/dblock/source/aws-sdk/aws-sdk-cpp/build/aws-sdk-cpp-config.cmake:1 (include)
  CMakeLists.txt:4 (find_package)


CMake Warning at CMakeLists.txt:4 (find_package):
  Found package configuration file:

    /Users/dblock/source/aws-sdk/aws-sdk-cpp/build/aws-sdk-cpp-config.cmake

  but it set aws-sdk-cpp_FOUND to FALSE so package "aws-sdk-cpp" is
  considered to be NOT FOUND.  Reason given by package:

  aws-sdk-cpp could not be found because dependency aws-c-event-stream could
  not be found.



-- Configuring done
-- Generating done
-- Build files have been written to: /Users/dblock/source/aws-sdk/list-s3-buckets/build

and

osx ~/source/aws-sdk/list-s3-buckets/build$ make
Scanning dependencies of target s3-sample
[ 50%] Building CXX object CMakeFiles/s3-sample.dir/main.cpp.o
/Users/dblock/source/aws-sdk/list-s3-buckets/main.cpp:2:10: fatal error: 'aws/core/Aws.h' file not found
#include <aws/core/Aws.h>
         ^~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/s3-sample.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/s3-sample.dir/all] Error 2
make: *** [all] Error 2

Seems like that blog post is out of date and these instructions don't work. Same problem on SO.

Tried various other things. How do I fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    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