aws-sdk-cpp icon indicating copy to clipboard operation
aws-sdk-cpp copied to clipboard

Compiling a static library with cmake reports an error, indicating missing aws-c-common and other related DLLs

Open xixi911 opened this issue 2 years ago • 8 comments

Describe the bug

I want to compile AWS using CMake into a static library, but I found that using the compiled static library results in an error indicating that aws-c-common.dll is missing.

Expected Behavior

Use the Static Library with no error

Current Behavior

微信图片_20240110100622 show lack of aws-c-common.dll

Reproduction Steps

cd C:/Users/Lenovo/Desktop/aws/aws-sdk-cpp/build cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:/Users/Lenovo/Desktop/aws/install -DBUILD_ONLY="core;s3" -DFORCE_SHARED_CRT=OFF -DBUILD_SHARED_LIBS=OFF .. cmake --build . --config Release cmake --install . --config Release

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11.225 (Built on windows 10)

Compiler and Version used

vs2017 sdk 10.0.22621.0

Operating System and version

Windows 10 Home

xixi911 avatar Jan 10 '24 02:01 xixi911

sorry,AWS CPP SDK version used is 1.11.238

xixi911 avatar Jan 10 '24 02:01 xixi911

Can you make sure you are using the latest and most up to date submodules with:

git submodule update --init --recursive

jmklix avatar Jan 10 '24 23:01 jmklix

Can you make sure you are using the latest and most up to date submodules with:

git submodule update --init --recursive

Can you make sure you are using the latest and most up to date submodules with:

git submodule update --init --recursive

I executed the command you provided, but there is still a problem with dll dependencies. I checked the compilation log and found there are linking issues. The file below is the log file log.txt

xixi911 avatar Jan 11 '24 02:01 xixi911

Looking at your log it seems to building and installing correclty, can you elaborate/include an example of how you are then using the SDK?

Use the Static Library with no error

how are you using the static library?

sbiscigl avatar Jan 11 '24 15:01 sbiscigl

Looking at your log it seems to building and installing correclty, can you elaborate/include an example of how you are then using the SDK?

Use the Static Library with no error

how are you using the static library?

"I have a dynamic DLL library that depends on the aws-cpp-sdk-core.lib and aws-cpp-sdk-s3.lib libraries. I found that both the static and dynamic libraries compile without any issues, and my dynamic library also uses MT for linking. However, when my program uses the dynamic library, it shows that aws-c-common.dll is missing. So, I compiled the dynamic version of aws-c-common, copied it in, and then it worked, but this is not the result I wanted." 1

xixi911 avatar Jan 12 '24 01:01 xixi911

Looking at your log it seems to building and installing correclty, can you elaborate/include an example of how you are then using the SDK?

Use the Static Library with no error

how are you using the static library? Not only the common dynamic library, but also the following dynamic libraries: aws-checksums.dll aws-c-event-stream.dll aws-crt-cpp.dll

xixi911 avatar Jan 12 '24 01:01 xixi911

I have a dynamic DLL library that depends on the aws-cpp-sdk-core.lib and aws-cpp-sdk-s3.lib libraries

How though in specific. i'm looking to see how you include them in your build. Please include the cmake files and commands you are using to create the dll and exe that uses your dll. also i will need examples of the full path that creates this issue. Im going to need reproducible samples to help you. so far i can see the dependency graph

(your exe) -- dynamic linked --> (your dll) -- static linked --> (aws sdk)

is that correct?

sbiscigl avatar Jan 12 '24 13:01 sbiscigl

I have a dynamic DLL library that depends on the aws-cpp-sdk-core.lib and aws-cpp-sdk-s3.lib libraries

How though in specific. i'm looking to see how you include them in your build. Please include the cmake files and commands you are using to create the dll and exe that uses your dll. also i will need examples of the full path that creates this issue. Im going to need reproducible samples to help you. so far i can see the dependency graph

(your exe) -- dynamic linked --> (your dll) -- static linked --> (aws sdk)

is that correct?

The process is as you described,but we've already addressed this issue by changing (your exe) -- dynamic linked --> (your dll) -- static linked --> (core.lib s3.lib) to (your exe) -- dynamic linked --> (your dll) -- static linked --> (core.lib s3.lib common.lib checksums.lib ........) However, I'm still a bit puzzled why it's showing a DLL error. If it's missing a static library, shouldn't it display a linking error?

xixi911 avatar Jan 13 '24 05:01 xixi911

What does your CMakeLists.txt file look like?

The suggested CMakeLists.txt found here currently fails for static builds. The fix for this is to not run AWSSDK_CPY_DYN_LIBS. You can do this with the following change:

if (WINDOWS_BUILD AND AWSSDK_INSTALL_AS_SHARED_LIBS)
    # Copy relevant AWS SDK for C++ libraries into the current binary directory for running and debugging.

    # set(BIN_SUB_DIR "/Debug") # if you are building from the command line you may need to uncomment this
    # and set the proper subdirectory to the executables' location.

    AWSSDK_CPY_DYN_LIBS(SERVICE_COMPONENTS "" ${CMAKE_CURRENT_BINARY_DIR}${BIN_SUB_DIR})
endif ()

Please let me know if this fixes your build problems.

jmklix avatar Apr 03 '24 21:04 jmklix

Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.

github-actions[bot] avatar Apr 14 '24 00:04 github-actions[bot]