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.
- Clone this repository with submodules
git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
-
Open the aws-sdk-cpp folder in Visual Studio
-
Configure CMake Settings
-
Open CMakeSettings.json by clicking on
Project
and thenCMake Settings for AWSSDK
(You might need to wait a few seconds for Visual Studio to generate the file) -
Add the following to
CMake command arguments
-DBUILD_ONLY="s3"
-
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
.
-
-
Click
Save and generate CMake cache to load variables
to do the same (or press Ctrl+S on CMakeSettings.json)
- 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 clickALL_BUILD
in the Solution Explorer and clickSet s Startup Project
-
Build this SDK by clicking on
Build
and thenBuild All
-
Install the SDK by clicking on
Build
and thenInstall AWSSDK
You have now successfully built and installed the aws-sdk-cpp. Now we will build and debug a "Hello S3" application.
-
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)
-
Now, if you haven't already, open up the folder with the sample application in a new Visual Studio window
-
Configure CMake Settings
-
Click
Save and generate CMake cache to load variables
to do the same (or press Ctrl+S on CMakeSettings.json) -
Change the startup item to
hello_s3.exe
by clicking the drop-down arrow next to the green play button -
Build the sample by clicking on
Build
and thenBuild hello_s3.exe
-
Run the sample by clicking the green play button next to
hello_s3.exe
-
Debug and use the SDK to your heart's content!