|
| 1 | +In this guide we will be setting up and running this ["Hello S3" application](https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/build-cmake.html) 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. |
| 2 | + |
| 3 | +1. Clone this repository with submodules |
| 4 | + ```sh |
| 5 | + git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp |
| 6 | + ``` |
| 7 | +2. Open the aws-sdk-cpp folder in Visual Studio |
| 8 | +3. Configure CMake Settings |
| 9 | + - 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) |
| 10 | + |
| 11 | +  |
| 12 | + |
| 13 | + - Add the following to `CMake command arguments` |
| 14 | + ```sh |
| 15 | + -DBUILD_ONLY="s3" |
| 16 | + ``` |
| 17 | + |
| 18 | +  |
| 19 | + |
| 20 | + - Other [CMake parameters](https://github.com/aws/aws-sdk-cpp/blob/main/docs/CMake_Parameters.md) can be added, but for this example we only need the above. |
| 21 | + - 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) |
| 22 | + - 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) |
| 23 | + - 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`. |
| 24 | +4. Click `Save and generate CMake cache to load variables` to do the same (or press Ctrl+S on CMakeSettings.json) |
| 25 | +
|
| 26 | +  |
| 27 | +
|
| 28 | +- 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` |
| 29 | +
|
| 30 | +5. Build this SDK by clicking on `Build` and then `Build All` |
| 31 | +
|
| 32 | +  |
| 33 | +
|
| 34 | +6. Install the SDK by clicking on `Build` and then `Install AWSSDK` |
| 35 | +
|
| 36 | +  |
| 37 | +
|
| 38 | +
|
| 39 | +You have now successfully built and installed the aws-sdk-cpp. Now we will build and debug a "Hello S3" application. |
| 40 | +
|
| 41 | +1. Follow `Step 1: Write the code` from the developer guide [here](https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/build-cmake.html). |
| 42 | + - Create a hello_s3 directory and/or project to hold your source files. |
| 43 | + - 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) |
| 44 | + - Add a CMakeLists.txt file that specifies your project’s name, executables, source files, and linked libraries. (Find code in above link) |
| 45 | +2. Now, if you haven't already, open up the folder with the sample application in a new Visual Studio window |
| 46 | +3. Configure CMake Settings |
| 47 | + - Open CMakeSettings.json by clicking on `Project` and then `CMake Settings for hello_s3` |
| 48 | + |
| 49 | +  |
| 50 | + |
| 51 | + - Add the following to `CMake command arguments` |
| 52 | + ```sh |
| 53 | + -DCMAKE_PREFIX_PATH="<path to installed location from above>" |
| 54 | + ``` |
| 55 | +  |
| 56 | + |
| 57 | + - Change any other CMake settings for your project at this time, if needed. |
| 58 | +4. Click `Save and generate CMake cache to load variables` to do the same (or press Ctrl+S on CMakeSettings.json) |
| 59 | + |
| 60 | +  |
| 61 | + |
| 62 | +5. Change the startup item to `hello_s3.exe` by clicking the drop-down arrow next to the green play button |
| 63 | + |
| 64 | +  |
| 65 | + |
| 66 | + |
| 67 | +6. Build the sample by clicking on `Build` and then `Build hello_s3.exe` |
| 68 | + |
| 69 | +  |
| 70 | + |
| 71 | +7. Run the sample by clicking the green play button next to `hello_s3.exe` |
| 72 | +8. Debug and use the SDK to your heart's content! |
0 commit comments