Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android NDK 23b LTS Compile Error #21438

Closed
4 tasks done
danoli3 opened this issue Jan 13, 2022 · 3 comments
Closed
4 tasks done

Android NDK 23b LTS Compile Error #21438

danoli3 opened this issue Jan 13, 2022 · 3 comments
Labels
category: build/install category: 3rdparty invalid platform: android question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org

Comments

@danoli3
Copy link
Contributor

danoli3 commented Jan 13, 2022

Hey! Please advise changes required I can PR fixes

Following Error for arm64/x86/x86_64 when targeting NDK 23b

Error at /opt/homebrew/Cellar/cmake/3.22.1/share/cmake/Modules/Platform/Android-Determine.cmake:584 (message):
  Android: CMAKE_ANDROID_ARM_MODE is set but is valid only for 'armeabi'

All is working with NDK target 21b in all architectures with the following build script

System information (version)
  • OpenCV => 4.5.5
  • Operating System / Platform => macOS ARM 64 Bit M1
  • Compiler => Clang++
Detailed description
android_configure: cmake config
NDK_VESION_MAJOR: 23
NDK_PLATFORM: android-21
ANDROID_NDK_HOME: /Users/one/Library/Android/sdk/ndk/23.1.7779620
SYSROOT: /Users/one/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot
Toolchain: /Users/one/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include
AR: /Users/one/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar
/Users/one/Library/Android/sdk/ndk/23.1.7779620
/Users/one/SOURCE/apothecary/apothecary/build/opencv/build_android_arm64
CMake Error at /opt/homebrew/Cellar/cmake/3.22.1/share/cmake/Modules/Platform/Android-Determine.cmake:584 (message):
  Android: CMAKE_ANDROID_ARM_MODE is set but is valid only for 'armeabi'
  architectures.
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.22.1/share/cmake/Modules/CMakeDetermineSystem.cmake:160 (include)
  CMakeLists.txt:113 (enable_language)


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.
-- Configuring incomplete, errors occurred!

 ^ Received error ^

Compilation Successful in NDK 23b:

  • arm-v7a / armv7

Failures in:

  • x86
  • x86_64
  • arm-v8a / arm64
Steps to reproduce

CMake Compile:

rm -rf $BUILD_FOLDER
    mkdir $BUILD_FOLDER
    cd $BUILD_FOLDER


    if [ "$ABI" = "armeabi-v7a" ]; then
      export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=TRUE"
    elif [ $ABI = "arm64-v8a" ]; then
      export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=TRUE"
    elif [ "$ABI" = "x86_64" ]; then
      export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=FALSE" 
    elif [ "$ABI" = "x86" ]; then
      export ARM_MODE="-DANDROID_FORCE_ARM_BUILD=FALSE"
    fi

    ANDROID_NDK=${NDK_ROOT}

    export ANDROID_NATIVE_API_LEVEL=21
  
    echo ${ANDROID_NDK}
    pwd
    cmake  \
      -DANDROID_TOOLCHAIN=clang++ \
      -DCMAKE_TOOLCHAIN_FILE=${NDK_ROOT}/build/cmake/android.toolchain.cmake  \
      -DCMAKE_CXX_COMPILER_RANLIB=${RANLIB} \
      -DCMAKE_C_COMPILER=${CC} \
      -DCMAKE_CXX_COMPILER=${CXX} \
      -DCMAKE_CXX_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++ -O3 -fPIC -Wno-implicit-function-declaration" \
      -DCMAKE_C_FLAGS="-fvisibility-inlines-hidden -stdlib=libc++ -O3 -fPIC -Wno-implicit-function-declaration " \
      ${ARM_MODE} \
      -D ANDROID_PLATFORM=${ANDROID_PLATFORM} \
      -DANDROID_ABI=${ABI} \
      -DBUILD_ANDROID_PROJECTS=OFF \
      -D BUILD_ANDROID_EXAMPLES=OFF \
      -D BUILD_opencv_objdetect=OFF \
      -D BUILD_opencv_video=OFF \
      -D BUILD_opencv_videoio=OFF \
      -D BUILD_opencv_features2d=OFF \
      -D BUILD_opencv_flann=OFF \
      -D BUILD_opencv_highgui=ON \
      -D BUILD_opencv_ml=ON \
      -D BUILD_opencv_photo=OFF \
      -D BUILD_opencv_python=OFF \
      -D BUILD_opencv_shape=OFF \
      -D BUILD_opencv_stitching=OFF \
      -D BUILD_opencv_superres=OFF \
      -D BUILD_opencv_ts=OFF \
      -D BUILD_opencv_videostab=OFF \
      -D WITH_MATLAB=OFF \
      -D WITH_CUDA=OFF \
      -DBUILD_SHARED_LIBS=OFF \
      -DBUILD_DOCS=OFF \
      -DBUILD_EXAMPLES=OFF \
      -DBUILD_FAT_JAVA_LIB=OFF \
      -DBUILD_JASPER=OFF \
      -DBUILD_PACKAGE=OFF \
      -DBUILD_opencv_java=OFF \
      -DBUILD_opencv_apps=OFF \
      -DBUILD_JPEG=OFF \
      -DBUILD_PNG=OFF \
      -DHAVE_opencv_androidcamera=OFF \
      -DWITH_CAROTENE=OFF \
      -DWITH_CPUFEATURES=OFF \
      -DWITH_TIFF=OFF \
      -DWITH_OPENEXR=OFF \
      -DWITH_1394=OFF \
      -DWITH_JPEG=OFF \
      -DWITH_PNG=OFF \
      -DWITH_FFMPEG=OFF \
      -DWITH_OPENCL=OFF \
      -DWITH_GIGEAPI=OFF \
      -DWITH_CUDA=OFF \
      -DWITH_CUFFT=OFF \
      -DWITH_JASPER=OFF \
      -DWITH_IMAGEIO=OFF \
      -DWITH_IPP=OFF \
      -DWITH_OPENNI=OFF \
      -DWITH_QT=OFF \
      -DWITH_V4L=OFF \
      -DWITH_PVAPI=OFF \
      -DWITH_EIGEN=OFF \
      -DBUILD_TESTS=OFF \
      -DANDROID_NDK=${NDK_ROOT} \
      -DCMAKE_BUILD_TYPE=Release \
      -DANDROID_ABI=$ABI \
      -DANDROID_STL=c++_static \
      -DANDROID_PLATFORM=$ANDROID_PLATFORM \
      -DCMAKE_TOOLCHAIN_FILE=$ANDROID_CMAKE_TOOLCHAIN \
      -DBUILD_PERF_TESTS=OFF ..
    make -j${PARALLEL_MAKE}
    make install
    
Issue submission checklist
  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues,
    forum.opencv.org, Stack Overflow, etc and have not found solution
  • I updated to latest OpenCV version and the issue is still there
  • There is reproducer code and related data files: videos, images, onnx, etc
@alalek
Copy link
Member

alalek commented Jan 13, 2022

Android: CMAKE_ANDROID_ARM_MODE is set but is valid only for 'armeabi'

OpenCV doesn't set this variable. Your script does that. You need to adopt this script for modern Android SDKs.

Error at /opt/homebrew/Cellar/cmake/3.22.1/share/cmake/Modules/Platform/Android-Determine.cmake:584

CMake's stuff.


IMHO, there is nothing to fix in OpenCV for this problem.

@danoli3
Copy link
Contributor Author

danoli3 commented Jan 14, 2022

Compiling successfully with CMake 3.18.1 packaged with Android SDK !!

I have reported this issue with CMake 3.22.1 directly to their issues, seems to be related to 3.22.1

https://gitlab.kitware.com/cmake/cmake/-/issues/23108

@danoli3
Copy link
Contributor Author

danoli3 commented Jan 21, 2022

Resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build/install category: 3rdparty invalid platform: android question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org
Projects
None yet
Development

No branches or pull requests

2 participants