1

I need to use AWS SDK in a project that has four configurations "Debug, RelWithDebInfo, MinSizeRel, and Release"

If I follow the instructions to build and install the SDK from source, it seems I can only have one configuration installed at a time. The docs say:

Generate the build files by running cmake. Specify on the cmake command line whether to build a Debug or Release version. Choose Debug throughout this procedure to run a debug configuration of your application code. Choose Release throughout this procedure to run a release configuration of your application code.

What is the intended usage in situations where I need to run both debug and release configurations of my application code? My project is currently in development I am frequently switching between debug and release configurations. This seems like it would be a common use case but I'm having some difficulty getting this set up.

If I just go with release config of the sdk, then when I try to build my project in debug I get:

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in AWSTest3.hello-world.obj

If I go with the debug sdk, when I try to build my project in release I get the reverse. That all make makes sense and is what I would expect under those conditions.

I tried installing both release and debug versions in separate directories, but linking them both in my project's cmakelists.txt is a challenge.

When I put into cmakelists.txt:

find_package(AWSSDK)
find_package(AWSSDKdebug)

Cmake finds the first one and skips the second one. The reason for this it turns out is because when it finds the package in the suggested folder the next thing it does is runs AWSSDKconfig.cmake in that folder. The first thing that file does is:

if(AWSSDK_FOUND)
    return()
endif()

When the second package hits that line is quits immediately. So it's very clear they don't intend you to have two separation installations of the SDK and link to each of them independently.

If I comment out that condition in the second library and it will find both packages. Next step is to link them.

AWS recommends linking with:

target_link_libraries(${PROJECT_NAME} PUBLIC ${AWSSDK_LINK_LIBRARIES})

${AWSSDK_LINK_LIBRARIES} is a variable that is set in AWSSDKconfig.cmake. Although whenever I try to print it it seems empty. It would seem like I need to link with something like:

find_package(AWSSDK)
target_link_libraries(${PROJECT_NAME} PUBLIC optimized ${AWSSDK_LINK_LIBRARIES})
find_package(AWSSDKdebug)
target_link_libraries(${PROJECT_NAME} PUBLIC debug ${AWSSDK_LINK_LIBRARIES})

When I use the above code I get:

CMake Error at source/projects/AWSTest3.hello-world/CMakeLists.txt:59 (target_link_libraries):
  The "optimized" argument must be followed by a library. 

If I leave "optimized" or "debug" out, it all links just fine. But the functionality of those specifiers is exactly what I need.

I've tried hacking AWSSDKconfig.cmake in different ways to force it to work, but the further I go in that direction clearer it becomes that this is not the right way to go about it.

Any input would be much appreciated. Thank you!

Joe Kaplan
  • 11
  • 2
  • Does this solve your problem? https://stackoverflow.com/questions/4080668/iterator-debug-level-value-0-doesnt-match-value-2 – Something Something Jan 29 '23 at 19:34
  • Just build each configuration into a separate directory? – Alan Birtles Jan 29 '23 at 19:37
  • Hi Alan, I tried that, per the last part of my post. The problem is the AWS SDK seems to go out of it's way to keep that from working. – Joe Kaplan Jan 29 '23 at 20:03
  • Can you try using separate scripts (or script that adjusts for debug/release command line switches), or build configurations + project settings if using a Visual Studio solution? – Dave S Jan 29 '23 at 20:09
  • How are you telling `AWSSDKconfig.cmake` where to look for the sdk? Presumably you're setting a variable? Can't you just set that variable differently for each configuration? – Alan Birtles Jan 29 '23 at 21:51
  • Thanks Alan. I added a bit more details in the top post about how this is set up. @Dave, I tried telling VS where to find the libs and headers manually in the project properties. I got a bunch of unresolved symbols. AWS-SDK really wants to be linked with 'target_link_libraries()' – Joe Kaplan Jan 29 '23 at 22:16

0 Answers0