aws / aws-sdk-cpp

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

Errors when building for Android #2452

Closed vinothkumarc2805 closed 1 year ago

vinothkumarc2805 commented 1 year ago

Describe the issue

While creating the AWS SDK C++ for Android as per the AWS SDK C++ documentation, I am getting the following error.

vinoth@vinoth-HP-245-G7-Notebook-PC:~/sdk_build$ cmake ../aws-sdk-cpp -DNDK_DIR="/home/vinoth/Android/Sdk/ndk/21.3.6528147/" -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCUSTOM_MEMORY_MANAGEMENT=ON -DTARGET_ARCH=ANDROID -DANDROID_NATIVE_API_LEVEL=21 -DCMAKE_PREFIX_PATH="/usr/local" -DLEGACY_MODE=OFF CMake Warning at CMakeLists.txt:9 (message): In 1.11 releases, we are releasing experimental alternative building mode.By setting -DLEGACY_MODE=OFF you can test our advances in modern CMake building and provide early feedback. The legacy support is set by default in 1.11, when you complete build updating scripts please update the build flags as mentioned in README.md and set -DLEGACY_BUILD=OFF. The legacy support will be removed at 1.12.0 release.

CMake Deprecation Warning at CMakeLists.txt:17 (cmake_policy): The OLD behavior for policy CMP0077 will be removed from a future version of CMake.

The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD.

-- Building AWS libraries as static objects -- Android ABI: none specified, defaulting to armeabi-v7a -- Android toolchain unspecified, defaulting to clang -- Android std lib: c++_shared -- Android API level: 21 -- Building project version: 1.11.62 -- Building Zlib as part of AWS SDK -- Encryption: LibCrypto -- Building Openssl as part of AWS SDK -- Http client: Curl -- Building Curl as part of AWS SDK CMake Error: The source directory "/home/vinoth/aws-sdk-cpp/android-build" does not exist. Specify --help for usage, or press the help button on the CMake GUI. CMake Error at cmake/build_external.cmake:139 (message): Failed to configure dependency libraries. Call Stack (most recent call first): CMakeLists.txt:198 (include)

-- Configuring incomplete, errors occurred!

Links

https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/setup-linux.html

jmklix commented 1 year ago

Can you confirm that this dir does exist and that you are running the cmake commands with the proper permissions to access this folder:

/home/vinoth/aws-sdk-cpp/android-build

This error:

CMake Error: The source directory "/home/vinoth/aws-sdk-cpp/android-build" does not exist.

points to something being wrong with this folder. You shouldn't need admin/sudo access to the folder but it could be blocked by that.

github-actions[bot] commented 1 year 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.

vinothkumarc2805 commented 1 year ago

The problem is the non existence of "android-build" folder inside the "aws-sdk-cpp" folder. i feel this suppose to be present in the aws-sdk-cpp in the latest code (main branch). However, When i refer the branch "version1.9", the "android-build" folder exists. Please recommend which branch to be used to create Andorid build.

ankurthegamedev commented 1 year ago

We are also facing the same issue sdk compiling fine for win and linux.But for android we are helples.

-- Building Curl as part of AWS SDK CMake Error: The source directory "/home//AWS/aws-sdk-cpp/android-build" does not exist. Specify --help for usage, or press the help button on the CMake GUI. CMake Error at cmake/build_external.cmake:139 (message): Failed to configure dependency libraries. Call Stack (most recent call first): CMakeLists.txt:198 (include)

yasminetalby commented 1 year ago

Hello @vinothkumarc2805 and @ankurgamedev ,

Thank you very much for your submissions and collaboration. I sincerely apologize for the delay of answer. There has been a restructuring of File Hierarchy of the project source code in v1.11.0 (see). As mentioned by @vinothkumarc2805 aws-sdk-cpp/android-build does exist in version prior to this change. I have created a backlog item to fix the issue you are currently experiencing.

In the meantime, are you able to work around this by using previous versions of the SDK?

Thank you once again for your time and for reporting this issue.

Sincerely,

Yasmine.

ankurthegamedev commented 1 year ago

Yes sdk 1.8 is compiling fine. But as a game project we have four build targets Win64 linux ios and android and want to stick with same latest sdk version. So a blog post or some sort of guide on how to update script and cmake files can be helpful for us.

yasminetalby commented 1 year ago

Thank you very much for your feedback @ankurgamedev! This makes sense. I will post an update here as soon as this issue is resolved. We really appreciate you reaching out and bringing this issue to our attention.

Sincerely,

Yasmine.

ankurthegamedev commented 1 year ago

### If you want build latest sdk for android change below files and it will compile successfully.Tested and Working.

Thanks

protsenko85 commented 1 year ago

### If you want build latest sdk for android change below files and it will compile successfully.Tested and Working.

  • IN ..\aws-sdk-cpp\cmake\build_external.cmake ->* change ${CMAKE_CURRENT_SOURCE_DIR}/android-build change it to ${CMAKE_CURRENT_SOURCE_DIR}/tools/android-build**
  • IN ..\aws-sdk-cpp\cmake\build_external.cmake ->remove extra -- before -j ${NUM_JOBS} it fixes the problem.***
  • IN ..\aws-sdk-cpp\tools\android-build\configure_openssl_cmake.py ——> change sourceDir = os.path.join(baseDir, "android-build", "cmakefiles", "openssl-cmake") to sourceDir = os.path.join(baseDir,”tools”,"android-build", "cmakefiles", "openssl-cmake")
  • IN ..\aws-sdk-cpp\tools\android-build\CMakeLists.txt -> CHANGE _python ${AWS_NATIVE_SDK_ROOT}/android-build/configure_opensslcmake.py to _python ${AWS_NATIVE_SDK_ROOT}/tools/android-build/configure_opensslcmake.py**
  • IN ..\aws-sdk-cpp\tools\android-build\CMakeLists.txt -> Change _${AWS_NATIVE_SDK_ROOT}/android-build/CurlAndroidCrossCompile.cmake to C ${AWS_NATIVE_SDKROOT}/tools/android-build/CurlAndroidCrossCompile.cmake**

Thanks

After using this fix i got a problem with OpelSSL `FAILED: CMakeFiles/install.util cmd.exe /C "cd /D C:_Projects\test_proj\build_sdk_android\external-build\ZLIB-prefix\src\ZLIB-build && "C:\Program Files\CMake\bin\cmake.exe" -P cmake_install.cmake" ninja: build stopped: subcommand failed. [3/16] Performing patch step for 'OPENSSL' FAILED: OPENSSL-prefix/src/OPENSSL-stamp/OPENSSL-patch C:/_Projects/test_proj/build_sdk_android/external-build/OPENSSL-prefix/src/OPENSSL-stamp/OPENSSL-patch cmd.exe /C "cd /D C:_Projects\test_proj\build_sdk_android\openssl-src && cd C:/_Projects/test_proj/build_sdk_android/external-build && python C:/_Projects/test_proj/aws-sdk-cpp/tools/android-build/configure_openssl_cmake.py --source C:/_Projects/test_proj/aws-sdk-cpp --dest C:/_Projects/test_proj/build_sdk_android/openssl-src && "C:\Program Files\CMake\bin\cmake.exe" -E touch C:/_Projects/test_proj/build_sdk_android/external-build/OPENSSL-prefix/src/OPENSSL-stamp/OPENSSL-patch" Python ninja: build stopped: subcommand failed. CMake Error at cmake/build_external.cmake:148 (message): Failed to build dependency libraries. Call Stack (most recent call first): CMakeLists.txt:198 (include)

-- Configuring incomplete, errors occurred!`

Do you know what could be the possible causes and solutions?

ankurthegamedev commented 1 year ago

Please provide cmake command you are using to build??

protsenko85 commented 1 year ago

@ankurgamedev here it is cmake ../aws-sdk-cpp -DNDK_DIR="C:\Users\prots\AppData\Local\Android\Sdk\ndk\21.4.7075529" -DBUILD_SHARED_LIBS=OFF -GNinja -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCUSTOM_MEMORY_MANAGEMENT=ON -DTARGET_ARCH=ANDROID -DANDROID_NATIVE_API_LEVEL=21 -DBUILD_ONLY="identity-management;s3"

ankurthegamedev commented 1 year ago

Try -G "Ninja" instead of -GNinja and cmake version 3.21.6 installed because as far as I know sdk has issues with latest cmake

protsenko85 commented 1 year ago

I have install cmake version 3.21.6 and changed cmake command to cmake ../aws-sdk-cpp -DNDK_DIR="C:\Users\prots\AppData\Local\Android\Sdk\ndk\21.4.7075529" -DBUILD_SHARED_LIBS=OFF -G "Ninja" -DENABLE_TESTING=OFF -DCMAKE_BUILD_TYPE=Release -DCUSTOM_MEMORY_MANAGEMENT=ON -DTARGET_ARCH=ANDROID -DANDROID_NATIVE_API_LEVEL=21 -DBUILD_ONLY="identity-management;s3" -DCMAKE_INSTALL_PREFIX="C:\_Projects\test_proj\install_sdk_android" Still having the same error

ankurthegamedev commented 1 year ago

Are you able to build for windows?? Have you installed visual studio llvm component for target cpu. Please share visual studio components installed?

protsenko85 commented 1 year ago

Yes, i am able to build for windows, problems start with build for android I just installed the Clang/LLVM component for VS, but it didn't change anything VS installed components list: "Microsoft.VisualStudio.Component.CoreEditor", "Microsoft.VisualStudio.Workload.CoreEditor", "Microsoft.VisualStudio.Component.NuGet", "Microsoft.Net.Component.4.6.1.TargetingPack", "Microsoft.VisualStudio.Component.Roslyn.Compiler", "Microsoft.VisualStudio.Component.Roslyn.LanguageServices", "Microsoft.VisualStudio.Component.FSharp", "Microsoft.ComponentGroup.ClickOnce.Publish", "Microsoft.NetCore.Component.DevelopmentTools", "Microsoft.VisualStudio.Component.FSharp.WebTemplates", "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions", "Microsoft.VisualStudio.Component.DockerTools", "Microsoft.NetCore.Component.Web", "Microsoft.Net.Component.4.8.SDK", "Microsoft.Net.Component.4.7.2.TargetingPack", "Microsoft.Net.ComponentGroup.DevelopmentPrerequisites", "Microsoft.VisualStudio.Component.TypeScript.4.3", "Microsoft.VisualStudio.Component.JavaScript.TypeScript", "Microsoft.VisualStudio.Component.JavaScript.Diagnostics", "Microsoft.Component.MSBuild", "Microsoft.VisualStudio.Component.TextTemplating", "Component.Microsoft.VisualStudio.RazorExtension", "Microsoft.VisualStudio.Component.IISExpress", "Microsoft.VisualStudio.Component.SQL.ADAL", "Microsoft.VisualStudio.Component.SQL.LocalDB.Runtime", "Microsoft.VisualStudio.Component.Common.Azure.Tools", "Microsoft.VisualStudio.Component.SQL.CLR", "Microsoft.VisualStudio.Component.MSODBC.SQL", "Microsoft.VisualStudio.Component.MSSQL.CMDLnUtils", "Microsoft.VisualStudio.Component.ManagedDesktop.Core", "Microsoft.Net.Component.4.5.2.TargetingPack", "Microsoft.Net.Component.4.5.TargetingPack", "Microsoft.VisualStudio.Component.SQL.SSDT", "Microsoft.VisualStudio.Component.SQL.DataSources", "Component.Microsoft.Web.LibraryManager", "Component.Microsoft.WebTools.BrowserLink.WebLivePreview", "Microsoft.VisualStudio.ComponentGroup.Web", "Microsoft.VisualStudio.Component.Web", "Microsoft.VisualStudio.ComponentGroup.Web.Client", "Microsoft.Net.Component.4.TargetingPack", "Microsoft.Net.Component.4.5.1.TargetingPack", "Microsoft.Net.Component.4.6.TargetingPack", "Microsoft.Net.ComponentGroup.TargetingPacks.Common", "Component.Microsoft.VisualStudio.Web.AzureFunctions", "Microsoft.VisualStudio.ComponentGroup.AzureFunctions", "Microsoft.VisualStudio.Component.Azure.Compute.Emulator", "Microsoft.VisualStudio.Component.Azure.Storage.Emulator", "Microsoft.VisualStudio.Component.Azure.ClientLibs", "Microsoft.VisualStudio.Component.Azure.AuthoringTools", "Microsoft.VisualStudio.Component.CloudExplorer", "Microsoft.VisualStudio.ComponentGroup.Web.CloudTools", "Microsoft.VisualStudio.Component.DiagnosticTools", "Microsoft.VisualStudio.Component.EntityFramework", "Microsoft.VisualStudio.Component.AspNet45", "Microsoft.VisualStudio.Component.AppInsights.Tools", "Microsoft.VisualStudio.Component.WebDeploy", "Microsoft.VisualStudio.Component.Debugger.JustInTime", "Component.Microsoft.VisualStudio.LiveShare", "Microsoft.VisualStudio.Component.WslDebugging", "Microsoft.VisualStudio.Component.IntelliCode", "Microsoft.NetCore.Component.Runtime.3.1", "Microsoft.NetCore.Component.Runtime.5.0", "Microsoft.NetCore.Component.SDK", "Microsoft.VisualStudio.Workload.NetWeb", "Microsoft.VisualStudio.Component.VC.CoreIde", "Microsoft.VisualStudio.Component.Windows10SDK", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "Microsoft.VisualStudio.Component.Graphics.Tools", "Microsoft.VisualStudio.Component.VC.DiagnosticTools", "Microsoft.VisualStudio.Component.Windows10SDK.19041", "Microsoft.ComponentGroup.Blend", "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", "Microsoft.VisualStudio.Component.VC.Redist.14.Latest", "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core", "Microsoft.VisualStudio.Component.VC.Tools.ARM64", "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.CMake", "Microsoft.VisualStudio.Component.VC.CMake.Project", "Microsoft.VisualStudio.Component.VC.ATL", "Microsoft.VisualStudio.Component.VC.TestAdapterForBoostTest", "Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest", "Microsoft.VisualStudio.Component.VC.CLI.Support", "Microsoft.VisualStudio.Component.VC.ASAN", "Microsoft.VisualStudio.Component.VC.Modules.x86.x64", "Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset", "Microsoft.VisualStudio.Component.VC.Llvm.Clang", "Component.IncredibuildMenu", "Component.Incredibuild", "Microsoft.VisualStudio.Component.Windows11SDK.22000", "Microsoft.VisualStudio.Component.Windows10SDK.18362", "Microsoft.VisualStudio.Workload.NativeDesktop", "Microsoft.Component.NetFX.Native", "Microsoft.VisualStudio.ComponentGroup.UWP.NetCoreAndStandard", "Microsoft.VisualStudio.Component.Graphics", "Microsoft.VisualStudio.ComponentGroup.UWP.Xamarin", "Microsoft.VisualStudio.ComponentGroup.UWP.Support", "Microsoft.VisualStudio.Component.UWP.VC.ARM64", "Microsoft.VisualStudio.Component.VC.Tools.ARM64EC", "Microsoft.VisualStudio.Component.UWP.VC.ARM64EC", "Microsoft.VisualStudio.Workload.Universal", "Component.OpenJDK", "Component.Android.SDK25.Private", "Component.Android.NDK.R16B", "Component.Ant", "Component.MDD.Android", "Microsoft.VisualStudio.Workload.NativeMobile", "Microsoft.VisualStudio.Workload.NativeGame", "Microsoft.VisualStudio.Component.VC.14.29.16.10.ARM", "Microsoft.VisualStudio.Component.VC.14.29.16.10.ARM.Spectre"

When i'm trying to build with VS 2019 - error is different: CLANGCOMPILE : error : unknown target CPU 'armv7-a' [C:\_Projects\test_proj\build_sdk_android\CMakeFiles\CMakeTmp\cmTC_98aa9.vcxproj]

When compile with Ninja error is still with OpenSSL

qiantanjingtao commented 1 year ago

### If you want build latest sdk for android change below files and it will compile successfully.Tested and Working.

  • IN ..\aws-sdk-cpp\cmake\build_external.cmake ->* change ${CMAKE_CURRENT_SOURCE_DIR}/android-build change it to ${CMAKE_CURRENT_SOURCE_DIR}/tools/android-build**
  • IN ..\aws-sdk-cpp\cmake\build_external.cmake ->remove extra -- before -j ${NUM_JOBS} it fixes the problem.***
  • IN ..\aws-sdk-cpp\tools\android-build\configure_openssl_cmake.py ——> change sourceDir = os.path.join(baseDir, "android-build", "cmakefiles", "openssl-cmake") to sourceDir = os.path.join(baseDir,”tools”,"android-build", "cmakefiles", "openssl-cmake")
  • IN ..\aws-sdk-cpp\tools\android-build\CMakeLists.txt -> CHANGE _python ${AWS_NATIVE_SDK_ROOT}/android-build/configure_opensslcmake.py to _python ${AWS_NATIVE_SDK_ROOT}/tools/android-build/configure_opensslcmake.py**
  • IN ..\aws-sdk-cpp\tools\android-build\CMakeLists.txt -> Change _${AWS_NATIVE_SDK_ROOT}/android-build/CurlAndroidCrossCompile.cmake to C ${AWS_NATIVE_SDKROOT}/tools/android-build/CurlAndroidCrossCompile.cmake**

Thanks

Maybe add one: change cmake/build_external.cmake : line 21, as following:

set(ZLIB_INCLUDE_DIR ${ZLIB_INSTALL_DIR}/include CACHE INTERNAL "zlib include dir")
github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.