AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
Visual_Studio_building_and_debugging

In this guide we will be setting up and running this "Hello S3" application in Visual Studio. This was tested with Visual Studio 2022 on Windows 10, but should work on other versions. First, we will start with building this SDK in Visual Studio.

  1. Clone this repository with submodules
    git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
  2. Open the aws-sdk-cpp folder in Visual Studio
  3. Configure CMake Settings
    • Open CMakeSettings.json by clicking on Project and then CMake Settings for AWSSDK (You might need to wait a few seconds for Visual Studio to generate the file)

      3 1 CMakeSettings

    • Add the following to CMake command arguments sh -DBUILD_ONLY="s3"

      3 2 Command arguments

    • Other CMake parameters can be added, but for this example we only need the above.
    • Change any other CMake settings for the aws-sdk-cpp at this time. e.g., Configuration type, Build root, Install directory, etc. (But you can leave them as default for this guide)
    • You can also change the cmake generator by clicking on Show advanced settings and selecting the generator that you want from the list. (Visual Studio 17 2022 works and is a decent choice if you don't know which to pick)
    • Note: The install directory defaults to ${projectDir}\out\install\${name} rather than the aws-sdk-cpp default on Windows of \Program Files (x86)\aws-cpp-sdk-all.
  4. Click Save and generate CMake cache to load variables to do the same (or press Ctrl+S on CMakeSettings.json)

    4 1 Save and generate CMake

  • Note: If you select a Visual Studio generator (rather than the default ninja), you will generate a solution file (.sln). You can then open this file as a project and complete the build and install steps from there. Before you build and install you will want to right click ALL_BUILD in the Solution Explorer and click Set s Startup Project
  1. Build this SDK by clicking on Build and then Build All

    5 1 Build

  2. Install the SDK by clicking on Build and then Install AWSSDK

    6 1 Install

You have now successfully built and installed the aws-sdk-cpp. Now we will build and debug a "Hello S3" application.

  1. Follow Step 1: Write the code from the developer guide here.
    • Create a hello_s3 directory and/or project to hold your source files.
    • Within that folder, add a hello_s3.cpp file that includes the following code, which reports the Amazon S3 buckets you own. (Find code in above link)
    • Add a CMakeLists.txt file that specifies your project’s name, executables, source files, and linked libraries. (Find code in above link)
  2. Now, if you haven't already, open up the folder with the sample application in a new Visual Studio window
  3. Configure CMake Settings
    • Open CMakeSettings.json by clicking on Project and then CMake Settings for hello_s3

      3 1 CMakeSettings 2

    • Add the following to CMake command arguments sh -DCMAKE_PREFIX_PATH="<path to installed location from above>" 3 2 Command arguments 2

Change any other CMake settings for your project at this time, if needed.

  1. Click Save and generate CMake cache to load variables to do the same (or press Ctrl+S on CMakeSettings.json)

    4 1 Save and generate CMake

  2. Change the startup item to hello_s3.exe by clicking the drop-down arrow next to the green play button

    5 1 Startup item

  3. Build the sample by clicking on Build and then Build hello_s3.exe

    6 1 Build hello_s3

  4. Run the sample by clicking the green play button next to hello_s3.exe
  5. Debug and use the SDK to your heart's content!