How to use AWS SDK purely statically #1900
-
Describe the issueBasically I do not want to use .dll files, only the .lib files. I am attempting to build the sdk statically by using the flags -DBUILD_SHARED_LIBS=OFF, -DFORCE_SHARED_CRT=OFF, and, if it is relevant, -DBUILD_ONLY="cognito-idp". This however results in a lot of errors. After doing a fail amount of digging online, seems these errors occur when trying to build statically something meant to use built as a dll. So, is it possible to use the library purely statically, or is using the .dll files necessary. Steps to ReproduceBuild the sdk with the flags -DBUILD_SHARED_LIBS=OFF, -DFORCE_SHARED_CRT=OFF, and, if it is relevant, -DBUILD_ONLY="cognito-idp". Current behaviorThe project is built using the following command:
This is successful. Then I execute the following command:
I receive the following errors and warnings:
AWS CPP SDK version usedlatest (main branch) compiler and version usedVisual Studio 2022 and msbuild Operating System and versionWindows 11 x64 (Same issue with 10 x64) |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 4 replies
-
Update: I tried building it with a different mix of flags, and it finally built successfully. It seems, though, that it can only be used with dlls, as now when using it in an actuall project I am received unresolved external errors referencing dllimports. Am I correct in assuming the sdk can only be used will dlls and there is no way to use it without? Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hi @HavenRemix you can use static build and it should only require static libs which are .lib files. I see that you have been setting the correct flags off ( |
Beta Was this translation helpful? Give feedback.
-
Hi, I build it using the following command line:
This builds successfully, however, it does not compile when used in the project. |
Beta Was this translation helpful? Give feedback.
-
What is the status of this issue? |
Beta Was this translation helpful? Give feedback.
-
Also running into the same issue, also wondering the current status. |
Beta Was this translation helpful? Give feedback.
-
Likewise here, I'm running into the same issue on the latest version. Edit: We managed to make it work statically in our Unreal project by adding the following windows dependencies:
|
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
I was able to successfully use the SDK as a static library in my project by building it with FORCE_SHARED_CRT=ON and BUILD_SHARE_LIBS=OFF.
When both are off, I got errors when trying to build the SDK binaries after generating them with CMAKE. With the configuration above, I was able to generate, build, and install. Afterward I had a bunch of lib files in my install directly that I was able to link to successfully.
As david-haim-sentinelone mentioned above, "It seems like there are only two mutually exclusive options here - link statically with dynamic CRT or link dynamically with static CRT."
I may be falling into first category there. But I did have success with it. I was browsing this b…