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

Unable to compile AWS SDK with Visual Studio 2017

Open ayushgupta-aic opened this issue 2 years ago • 12 comments

Describe the bug

Unable to compile the v1.11 (or even the main branch) CPP SDK source code using VS 2017 and Windows SDK 10.0.22000.0

Expected Behavior

Expect to compile fine

Current Behavior

C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\rpcnsi.h(368): error C2872: 'UUID': ambiguous symbol (compiling source file C:\work\awscppsdk\aws-sdk-cpp-build\src\aws-cpp-sdk-core\ub_core.cpp) 13>C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\rpcdce.h(83): note: could be 'GUID UUID' (compiling source file C:\work\awscppsdk\aws-sdk-cpp-build\src\aws-cpp-sdk-core\ub_core.cpp) 13>C:\work\awscppsdk\aws-sdk-cpp\src\aws-cpp-sdk-core\include\aws/core/utils/UUID.h(21): note: or 'Aws::Utils::UUID' (compiling source file C:\work\awscppsdk\aws-sdk-cpp-build\src\aws-cpp-sdk-core\ub_core.cpp)

Reproduction Steps

Build commands: cmake -G "Visual Studio 15 2017 Win64" c:\work\awscppsdk\aws-sdk-cpp -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="core;s3;glacier;sqs;sns" -DBUILD_SHARED_LIBS=FALSE -DFORCE_SHARED_CRT=FALSE -DENABLE_TESTING=FALSE followed by compilation of the projects in Visual Studio 2017

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11

Compiler and Version used

Visual Studio 2017/ Windows SDK 10.0.22000.0

Operating System and version

Windows 11

ayushgupta-aic avatar Sep 04 '23 09:09 ayushgupta-aic

Hello @ayushgupta-aic ,

Thank you very much for your submission. It seems that their might be an issue with how you are qualifying UUID in your rpcnsi.h file. C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\rpcnsi.h(368): error C2872: 'UUID': ambiguous symbol

If you intend to use Aws::Utils::UUID need help with this, could you please provide a snippet of your code and use case of UUID in rpcnsi.f ?

Best,

Yasmine

yasminetalby avatar Sep 05 '23 13:09 yasminetalby

@yasminetalby : Thanks for your response. We are just trying to compile the AWS CPP codebase. It does not include any of our custom code. rpcnsi.h is part of Windows SDK.

More specifically, while trying to compile the aws-cpp-sdk-core project. Attached if the full compilation log aws-cpp-sdk-core.log

ayushgupta-aic avatar Sep 05 '23 14:09 ayushgupta-aic

Hello @ayushgupta-aic ,

Thank you very much for your response and for providing the logs. It seems that there is a conflict issue with the Windows SDK definition of UUID typedef GUID UUID Working on a fix right now!

Best,

Yasmine

yasminetalby avatar Sep 06 '23 12:09 yasminetalby

Hello @ayushgupta-aic ,

This issue should be fixed in v1.11.162 of the SDK. Let me know if this resolves your issue.

Thank you very much for your collaboration.

Best regards,

Yasmine

yasminetalby avatar Sep 13 '23 11:09 yasminetalby

hi @yasminetalby . I am still encountering the same errors. Tried with both v1.11.162 and v1.11.163

ayushgupta-aic avatar Sep 14 '23 05:09 ayushgupta-aic

@yasminetalby : Any update on this?

ayushgupta-aic avatar Oct 02 '23 11:10 ayushgupta-aic

Are you still running into this with the latest version of the sdk? I've tried reproducing this, but I can't seem to reproduce the same error that you are seeing.

jmklix avatar Mar 13 '24 21:03 jmklix

Hi Joseph, Can you please let me know which version/ tag I should try with?

Thanks, Ayush


From: Joseph Klix @.> Sent: Thursday, March 14, 2024 3:20 AM To: aws/aws-sdk-cpp @.> Cc: Ayush Gupta @.>; Mention @.> Subject: Re: [aws/aws-sdk-cpp] Unable to compile AWS SDK with Visual Studio 2017 (Issue #2656)

Are you still running into this with the latest version of the sdk? I've tried reproducing this, but I can't seem to reproduce the same error that you are seeing.

— Reply to this email directly, view it on GitHubhttps://github.com/aws/aws-sdk-cpp/issues/2656#issuecomment-1995924253, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALLCYEX5YQERUASDZLY5AZDYYDC3JAVCNFSM6AAAAAA4KFEIIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJVHEZDIMRVGM. You are receiving this because you were mentioned.Message ID: @.***>

ayushgupta-aic avatar Mar 14 '24 01:03 ayushgupta-aic

Using the latest version is always our recommendation. Currently that is 1.11.285

jmklix avatar Mar 14 '24 16:03 jmklix

Hi Joseph, I noticed that the latest (1.11.285) doesn't quite build correctly.

I am using cmake this time. The command line is:

cmake D:\work\awscppsdk\aws-sdk-cpp -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=D:\work\awscppsdk\output\release -DBUILD_ONLY="core;s3;glacier;sqs;sns" -DFORCE_SHARED_CRT=FALSE -DBUILD_SHARED_LIBS=FALSE -DENABLE_TESTING=FALSE

Note that i am trying to build a static library that i can link to.

However, when i tried to link to it from my project in visual studio 2019, i got errors:

3>LIBCMT.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library 3>aws-c-common.lib(allocator.obj) : error LNK2001: unresolved external symbol __imp__aligned_free 3>aws-c-common.lib(allocator.obj) : error LNK2001: unresolved external symbol __imp__aligned_malloc 3>aws-c-common.lib(allocator.obj) : error LNK2001: unresolved external symbol __imp__aligned_realloc 3>aws-c-common.lib(date_time.obj) : error LNK2001: unresolved external symbol __imp_modf 3>aws-c-common.lib(date_time.obj) : error LNK2001: unresolved external symbol __imp_round 3>aws-c-common.lib(environment.obj) : error LNK2001: unresolved external symbol __imp__putenv_s 3>aws-c-common.lib(process.obj) : error LNK2001: unresolved external symbol __imp__getpid 3>D:\Work\gateway\code\user\x64\Release\awsext.dll : fatal error LNK1120: 7 unresolved externals

Upon further inspection of , I found that the aws-c-common project, I noticed that it had incorrect configuration. The runtime library is set to Multi-threaded DLL (/MD). It should be Multi-threaded (/MT). For rest of the projects in AWSSDK.sln, it seems correct. Once I fixed that manually in the project and used cmake to build again, I did not get the above errors while linking with the libraries. However, I did get another error:

error LNK2005: "public: class std::basic_iostream<char,struct std::char_traits > & __cdecl Aws::Utils::Stream::ResponseStream::GetUnderlyingStream(void)const " @.@@.@Aws@@@.@.@std@@@std@@XZ) already defined in aws-cpp-sdk-core.lib(ub_core.obj) fatal error LNK1169: one or more multiply defined symbols found


From: Joseph Klix @.> Sent: 14 March 2024 22:08 To: aws/aws-sdk-cpp @.> Cc: Ayush Gupta @.>; Mention @.> Subject: Re: [aws/aws-sdk-cpp] Unable to compile AWS SDK with Visual Studio 2017 (Issue #2656)

Using the latest version is always our recommendation. Currently that is 1.11.285https://github.com/aws/aws-sdk-cpp/releases/tag/1.11.285

— Reply to this email directly, view it on GitHubhttps://github.com/aws/aws-sdk-cpp/issues/2656#issuecomment-1997873189, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALLCYEX3EAPQJCFNGVKEHZLYYHHAXAVCNFSM6AAAAAA4KFEIIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJXHA3TGMJYHE. You are receiving this because you were mentioned.Message ID: @.***>

ayushgupta-aic avatar Mar 19 '24 02:03 ayushgupta-aic

Can you add -DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON to your cmake config. Also just as a reminder please make sure you're using the same MSVC runtime version.

I'm able to successfully build on windows with the following:

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="<install-path>" -DBUILD_ONLY="s3;glacier;sqs;sns;core" -DFORCE_SHARED_CRT=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_TESTING=OFF -DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON

Can you make sure your build and install directories are clean while doing this?

jmklix avatar Mar 22 '24 18:03 jmklix

Hi Joesph, I tried with tag 1.11.297. Here are my observations:

Using the DAWS_STATIC_MSVC_RUNTIME_LIBRARY flag, the libs now build correctly (all static) * However, when i try to link to the libs in my Visual Studio project I get an error public: class std::basic_iostream<char,struct std::char_traits > & __cdecl Aws::Utils::Stream::ResponseStream::GetUnderlyingStream(void)const " @.@@.@Aws@@@.@.@std@@@std@@XZ) already defined in aws-cpp-sdk-core.lib(ub_core.obj)

More specifically, if I have narrowed it down to:

objectRequest.WithBucket(awsBucketName).WithKey(awsObjectName); getObjectOutcome = pS3Client->GetObject(objectRequest); if (getObjectOutcome.IsSuccess()) { Aws::OFStream local_file; local_file.open(cachePath, std::ios::out | std::ios::binary); local_file << getObjectOutcome.GetResult().GetBody().rdbuf(); // Having this in the code results in the above mentioned linker error. Worked fine with version 1.7.365 version of the SDK. auto meta = getObjectOutcome.GetResult().GetMetadata(); LOG_INFO ("Fetched %S/%s", bucketName, awsObjectName.c_str()); }


From: Joseph Klix @.> Sent: 23 March 2024 00:15 To: aws/aws-sdk-cpp @.> Cc: Ayush Gupta @.>; Mention @.> Subject: Re: [aws/aws-sdk-cpp] Unable to compile AWS SDK with Visual Studio 2017 (Issue #2656)

Can you add -DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON to your cmake config. Also just as a reminder please make sure you're using the same MSVC runtime version.

I'm able to successfully build on windows with the following:

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="" -DBUILD_ONLY="s3;glacier;sqs;sns;core" -DFORCE_SHARED_CRT=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_TESTING=OFF -DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON

Can you make sure your build and install directories are clean while doing this?

— Reply to this email directly, view it on GitHubhttps://github.com/aws/aws-sdk-cpp/issues/2656#issuecomment-2015704890, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALLCYESRRURUIPAXTZ3NEPTYZR33ZAVCNFSM6AAAAAA4KFEIIGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVG4YDIOBZGA. You are receiving this because you were mentioned.Message ID: @.***>

ayushgupta-aic avatar Apr 01 '24 07:04 ayushgupta-aic