Search code examples
c++amazon-web-servicesaws-sdk

ALLOCATION_TAG not a member "Aws::S3::S3Client"


I have an error

ALLOCATION_TAG not a member "Aws::S3::S3Client".

for this code

#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
#include <aws/s3/model/ListObjectsV2Request.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <aws/s3/model/HeadObjectRequest.h>
#include <aws/core/auth/AWSCredentials.h>
...

Aws::S3::S3Client s3Client(awsCredentials,
                               Aws::MakeShared<Aws::S3::S3EndpointProvider>(Aws::S3::S3Client::ALLOCATION_TAG),
                               awsConfig);

This code is working fine for my colleagues. I guess that the problem deals with ASW SDK installation process

My actions: 1 Download Visual Studio for C++ development 2 Open developer comand prompt for VS2022 3 Run the following commands

git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
mkdir sdk_build
cd sdk_build
cmake ..\aws-sdk-cpp -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="C:\\Program Files\\aws-cpp-sdk-all"
cmake --build . --config=Release
cmake --install . --config=Release

I was restarting PC, but it didn't help. My Cmake

cmake_minimum_required(VERSION 3.23)
project(Launcher)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 14)
set(AWSSDK_ROOT "C://Program Files (x86)//aws-cpp-sdk-all")


find_package(Qt6 COMPONENTS Widgets Concurrent REQUIRED)
find_package(AWSSDK REQUIRED COMPONENTS s3 cognito-idp cognito-identity)
add_compile_definitions(AWS_NO_STATIC_IMPL)

add_executable(${PROJECT_NAME}
        ...
        main.cpp)

target_include_directories(${PROJECT_NAME} PRIVATE ${AWSSDK_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} PRIVATE ${AWSSDK_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Widgets Qt6::Concurrent)

How to fix this error?


Solution

  • This change was introduced on Feb 8. If your colleagues do not run into this, it is because they have not updated their AWS SDK and your CI environment has not, either. You should contact your colleagues and agree on 1) which version of the AWS SDK to use and 2) a process for upgrading to newer versions. (which would unearth problems like this)

    The long-term fix is to pass Aws::S3::S3Client::getAllocationTag() instead. The short-term fix is to use an older version of the SDK.