aws / aws-sdk-cpp

AWS SDK for C++
Apache License 2.0
1.97k stars 1.06k forks source link

Unable to compile AWS SDK with Visual Studio 2017 #2656

Closed ayushgupta-aic closed 5 months ago

ayushgupta-aic commented 1 year ago

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

yasminetalby commented 1 year ago

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

ayushgupta-aic commented 1 year ago

@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

yasminetalby commented 1 year ago

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 commented 1 year ago

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

ayushgupta-aic commented 1 year ago

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

ayushgupta-aic commented 1 year ago

@yasminetalby : Any update on this?

jmklix commented 8 months ago

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.

ayushgupta-aic commented 8 months ago

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: @.***>

jmklix commented 8 months ago

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

ayushgupta-aic commented 7 months ago

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 impaligned_free 3>aws-c-common.lib(allocator.obj) : error LNK2001: unresolved external symbol impaligned_malloc 3>aws-c-common.lib(allocator.obj) : error LNK2001: unresolved external symbol impaligned_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 impputenv_s 3>aws-c-common.lib(process.obj) : error LNK2001: unresolved external symbol impgetpid 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: @.***>

jmklix commented 7 months ago

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?

ayushgupta-aic commented 7 months ago

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: @.***>

jmklix commented 5 months ago

Can you take a look at this guide I'm working for how to build this sdk in Visual Studio. Please let me know if you have any questions and/or if you still can't get the sdk to build in Visual Studio 2017

github-actions[bot] commented 5 months ago

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.