1

I am trying to run aws-sdk-cpp in Ubuntu by following the developer guide at https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/basic-use.html.

What I did are:

1. Install the sdk

sudo apt-get install cmake
sudo apt-get install uuid
sudo apt-get install libcurl4-openssl-dev
git clone https://github.com/aws/aws-sdk-cpp.git
cd aws-sdk-cpp
mkdir sdk_build
cd sdk_build
cmake3 .. -DBUILD_ONLY=s3
make

2. Create the test file test.cpp

#include <iostream>
#include <aws/core/Aws.h>
using namespace std;

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

    //use the sdk

    Aws::ShutdownAPI(options);
    cout << "Hello, World!";
    return 0;
}

3. Compile

g++ -o test test.cpp

Then I got the error:

/tmp/ccAA9bE5.o: In function `main':
test.cpp:(.text+0x34): undefined reference to `Aws::InitAPI(Aws::SDKOptions const&)'
test.cpp:(.text+0x3c): undefined reference to `Aws::ShutdownAPI(Aws::SDKOptions const&)'
collect2: error: ld returned 1 exit status

My question:

How can I fix the issue in order to compile and run the aws-sdk-cpp? Did I miss any installation steps?

Thank you!

Gold Chicken
  • 333
  • 6
  • 15
  • You have to link the library in order to make it work. Something like `-laws-sdk-cpp` or whatever the name of the library. Also using cmake helps so maybe try using that. – Waqar Mar 16 '20 at 07:23
  • Unrelated to your problem but you probably want to checkout a [release](https://github.com/aws/aws-sdk-cpp/releases) rather than the master branch, e.g. add "git checkout tags/1.7.296" after "git clone" – Alan Birtles Mar 16 '20 at 07:27
  • https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/build-cmake.html – Waqar Mar 16 '20 at 07:27
  • Thanks all. I managed to solve it by using cmake and linnk the library. – Gold Chicken Mar 16 '20 at 08:09

0 Answers0