1

We previously built aws-sdk-cpp locally and designed a library around it. Now I'm upgrading to use Conan provided aws-sdk-cpp instead of a locally built one, but I'm getting errors from our library.

I call AWS functions such as the following,

std::string src_bucket;
DeleteObject
// ...

obj.WithBucket(src_bucket).WithDelete(std::move(del));

but I get errors like this.

error: no matching function for call to 'Aws::S3::Model::DeleteObjectsRequest::WithBucket(const string&)`.

Has this function call changed to now allow std::string? Is there a way to make AWS methods accept std::string?

the_storyteller
  • 2,335
  • 1
  • 26
  • 37

1 Answers1

2

Is there a way to make AWS methods accept std::string?

Yes. These functions accept std::string if custom memory management is disabled:

If the compile-time constant is enabled (on), the types resolve to STL types with a custom allocator connected to the AWS memory system.

If the compile-time constant is disabled (off), all Aws::* types resolve to the corresponding default std::* type.

It looks like the former is what you get, and the latter is what you expect - perhaps you've switched from linking the SDK statically (default off) to linking the SDK dynamically (default on)?

In any case, you'll either have to somehow build the SDK with custom memory management disabled, use types like Aws::String yourself, or convert between Aws::String and std::string as needed.

Wander Nauta
  • 18,832
  • 1
  • 45
  • 62
  • The Conan library wasn't setting the `BUILD_SHARED_LIBS` CMake definition, even though the `aws-sdk-cpp:shared` Conan option was set to `False`. – the_storyteller Sep 02 '21 at 19:36
  • Conan will probably be setting ``BUILD_SHARED_LIBS=ON`` only when ``aws-sdk-cpp:shared=True``, as the opposite is the default, and is not expected to be set to OFF by the library CMakeLists.txt. I think the new ``CMakeToolchain`` integration sets it to OFF and ON based on the ``options.shared`` value. – drodri Sep 03 '21 at 20:49