aws / aws-lc-rs

aws-lc-rs is a cryptographic library using AWS-LC for its cryptographic operations. The library strives to be API-compatible with the popular Rust library named ring.
Other
320 stars 49 forks source link

Android ndk 27.0.11902837 error but 28.0.12433566 success #566

Closed songjiachao closed 1 month ago

songjiachao commented 1 month ago

Problem:

When I use ndk 27.0.11902837 got error

--- stderr
  Evaluating: AWS_LC_SYS_EXTERNAL_BINDGEN='1'
  Parsed: AWS_LC_SYS_EXTERNAL_BINDGEN=true
  CMake Deprecation Warning at CMakeLists.txt:4 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.

  CMake Error at /Users/vivo/Library/Android/sdk/cmake/3.30.4/share/cmake-3.30/Modules/Platform/Android-Determine.cmake:218 (message):
    Android: Neither the NDK or a standalone toolchain was found.
  Call Stack (most recent call first):
    /Users/vivo/Library/Android/sdk/cmake/3.30.4/share/cmake-3.30/Modules/CMakeDetermineSystem.cmake:184 (include)
    CMakeLists.txt:6 (project)

  CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
  thread 'main' panicked at /Users/vivo/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cmake-0.1.51/src/lib.rs:1100:5:

  command did not execute successfully, got: exit status: 1

  build script failed, must exit now
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

but use 28.0.12433566 success

❯ clang -v
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
justsmth commented 1 month ago

Hello again!

There's is a known issue with NDK r27. This was discussed in a previous issue here.

However, in this case the problem is indicated by this line:

...
  CMake Error at /Users/vivo/Library/Android/sdk/cmake/3.30.4/share/cmake-3.30/Modules/Platform/Android-Determine.cmake:218 (message):
    Android: Neither the NDK or a standalone toolchain was found.
...

You can see the logic that generates this error message here:

...
if(NOT CMAKE_ANDROID_NDK AND NOT CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
  message(FATAL_ERROR "Android: Neither the NDK or a standalone toolchain was found.")
endif()
...

So CMake was not able to identify the NDK or toolchain. A few lines above that, you can see which environment variables CMake uses to locate these:

...
  elseif(IS_DIRECTORY "$ENV{ANDROID_NDK_ROOT}")
    file(TO_CMAKE_PATH "$ENV{ANDROID_NDK_ROOT}" CMAKE_ANDROID_NDK)
  elseif(IS_DIRECTORY "$ENV{ANDROID_NDK}")
    file(TO_CMAKE_PATH "$ENV{ANDROID_NDK}" CMAKE_ANDROID_NDK)
  elseif(IS_DIRECTORY "$ENV{ANDROID_STANDALONE_TOOLCHAIN}")
    file(TO_CMAKE_PATH "$ENV{ANDROID_STANDALONE_TOOLCHAIN}" CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
  endif()
...

You might be able to fix this by setting (and exporting) ANDROID_NDK_ROOT or ANDROID_NDK to the location of the NDK in your build environment.

I hope this resolves your build issue!