Skip to content

Explaination for build_sdk.py #10448

Closed
Closed

Description

@hannesa2
System information (version)
  • OpenCV => 3.4
  • Operating System / Platform => Mac
Detailed description

I try to build OpenCV for Android by my own on my Mac, inspired by this log I installed the exact NDK android-ndk-r10e

and I was forced to install ninja by brew install ninja
but currently I see

CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set

But I need some explanation for
buildenv python ../opencv/platforms/android/build_sdk.py --build_doc --extra_pack 2.4.13:/opt/android/pack_2.4/ . ../opencv

What is

  • buildenv how does it looks like ?
  • --extra_pack what is the content of /opt/android/pack_2.4/ ?
  • how to get rid of CMAKE_MAKE_PROGRAM is not set ?

Activity

  1. alalek commented on Dec 28, 2017

    @alalek
    Member
    • buildenv: standard ANDROID_SDK / ANDROID_NDK / NDKROOT / Java env variables
    • ignore --extra-pack: it is for bundling OpenCV 2.4 into OpenCV Manager for Android package (deprecated component)
    • try cleaning build directory, check that "ninja" command works from terminal (adjust PATH env variable if required)
  2. hannesa2 commented on Dec 28, 2017

    @hannesa2
    ContributorAuthor

    Thank you for the clarification. I only works on command line, and ninja works on any directory which contains a build.ninjafile.
    With python ../opencv/platforms/android/build_sdk.py . ../opencv I get

    Executing: ['cmake', '-GNinja', "-DCMAKE_TOOLCHAIN_FILE='/Users/hannes/git/openCV/opencv/platforms/android/android.toolchain.cmake'", '-DWITH_OPENCL=OFF', '-DWITH_CUDA=OFF', '-DWITH_IPP=OFF', '-DBUILD_EXAMPLES=OFF', '-DBUILD_TESTS=OFF', '-DBUILD_PERF_TESTS=OFF', '-DBUILD_DOCS=OFF', '-DBUILD_ANDROID_EXAMPLES=ON', '-DINSTALL_ANDROID_EXAMPLES=ON', '-DANDROID_STL=gnustl_static', '-DANDROID_NATIVE_API_LEVEL=9', "-DANDROID_ABI='armeabi-v7a with NEON'", '-DWITH_TBB=ON', '-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8', '/Users/hannes/git/openCV/opencv', '-DNDK_CCACHE=ccache', '-DBUILD_TESTS=ON', '-DINSTALL_TESTS=ON']
    CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.

    Any help is welcome !

  3. alalek commented on Dec 28, 2017

    @alalek
    Member

    CMake Error: CMake was unable to find a build program corresponding to "Ninja".

    Problem is here. CMake is not able to find it.

    Does "ninja --version" command work? (without any additional paths)

    BTW, Also you could try removing option "-GNinja" from the build script (CMake should use "make" tool instead)


    Update 2018-01-04: Looks like modern CMake versions don't want to search "ninja" automatically. You need to pass this option: -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja

  4. hannesa2 commented on Dec 28, 2017

    @hannesa2
    ContributorAuthor

    ninja --version works properly.

    image

    As suggested, I removed both lines -GNinja from ./opencv/platforms/android/build_sdk.py

    image

    .. yes it starts ! But after 30 seconds, I see after configuring and generation this now

    -- Install to: /Users/hannes/git/openCV/build/o4a/install


    --
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/hannes/git/openCV/build/o4a
    Executing: ['ninja']
    ninja: error: loading 'build.ninja': No such file or directory
    Traceback (most recent call last):
    File "../opencv/platforms/android/build_sdk.py", line 303, in
    builder.build_library(abi, do_install)
    File "../opencv/platforms/android/build_sdk.py", line 149, in build_library
    execute(["ninja"])
    File "../opencv/platforms/android/build_sdk.py", line 20, in execute
    raise Fail("Child returned: %s" % retcode)
    main.Fail: Child returned: 1

    Why is there ninja used, when it build without (more) too ? It adds more complexity, and as I see OpenCV has enough of it

  5. hannesa2 commented on Dec 28, 2017

    @hannesa2
    ContributorAuthor

    after the next change
    image

    I run into this

    -- Installing: /Users/hannes/git/openCV/build/o4a/install/sdk/etc/valgrind_3rdparty.supp
    CMake Error at 3rdparty/cpufeatures/cmake_install.cmake:41 (file):
    file INSTALL cannot find
    "/Users/hannes/git/openCV/build/o4a/3rdparty/lib/armeabi-v7a/libcpufeatures.a".
    Call Stack (most recent call first):
    cmake_install.cmake:110 (include)

    Traceback (most recent call last):
    File "../opencv/platforms/android/build_sdk.py", line 303, in
    builder.build_library(abi, do_install)
    File "../opencv/platforms/android/build_sdk.py", line 151, in build_library
    execute(["cmake", "-DCOMPONENT=%s" % c, "-P", "cmake_install.cmake"])
    File "../opencv/platforms/android/build_sdk.py", line 20, in execute
    raise Fail("Child returned: %s" % retcode)
    main.Fail: Child returned: 1

    Any ideas ?

  6. alalek commented on Dec 28, 2017

    @alalek
    Member

    "next" change with "ninja" should be "make" (or "cmake --build .")

  7. hannesa2 commented on Dec 28, 2017

    @hannesa2
    ContributorAuthor

    image

    Yes ! It builds now. 👍
    Make it sense to make a PR with my changes, or is it just for "private purpose" ?

  8. alalek commented on Dec 28, 2017

    @alalek
    Member

    "ninja" is faster than "make", so we prefer to use it. Usually there are no problems to properly install "ninja".

  9. hannesa2 commented on Dec 28, 2017

    @hannesa2
    ContributorAuthor

    Next issue is how to specify lib_target_sdk_target ?

    [ 91%] Generating OpenCV Android library project. SDK target: lib_target_sdk_target-NOTFOUND


    The "android" command is deprecated.
    For manual SDK, AVD, and project management, please use Android Studio.
    For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager


    Invalid or unsupported command "--silent create lib-project --path /Users/hannes/git/openCV/build/o4a --target lib_target_sdk_target-NOTFOUND --name OpenCV --package org.opencv"

    Supported commands are:
    android list target
    android list avd
    android list device
    android create avd
    android move avd
    android delete avd
    android list sdk
    android update sdk
    make[2]: *** [build.xml] Error 2
    make[1]: *** [modules/java/CMakeFiles/opencv_java.dir/all] Error 2
    make: *** [all] Error 2
    Traceback (most recent call last):
    File "../opencv/platforms/android/build_sdk.py", line 303, in
    builder.build_library(abi, do_install)
    File "../opencv/platforms/android/build_sdk.py", line 149, in build_library
    execute(["make"])
    File "../opencv/platforms/android/build_sdk.py", line 20, in execute
    raise Fail("Child returned: %s" %

  10. alalek commented on Dec 29, 2017

    @alalek
    Member

    I believe this can be fixed with old Android SDK only (we using some snapshot from 2015/2016 year):

    BTW, modern version of "build tools" component requires Java 8.

    Also you could try these changes: #10288

  11. hannesa2 commented on Dec 29, 2017

    @hannesa2
    ContributorAuthor

    My motivation/vision is to make is usable out of the box with Android Studio 3 without copy anything somewhere. (or at least to help to go in this direction)

    But when I see the spirit in #10288 I've no chance to do so, so there is no need anymore to understand exactly the current build process and help to improve it.

    Currently I'm a copy-guy as all other does. -sad-

    If there is any change in this spirit, I hope I will mention it and I will help to improve it.
    What should be done here for Android

    • any commit should be tested prior merge for all platforms with eg Travis, like in Tensorflow
    • build an Android lib and deploy to jcenter or similar
    • Android sample project with Android Studio
    • no delivery with zip, just jcenter or similar to have something like implements "com.opencv.lib:3.4.0" in build.gradle
    • no generation of *.java files
  12. mshabunin commented on Dec 29, 2017

    @mshabunin
    Contributor

    @hannesa2 , please check this issue: #5003

  13. sergiomarqmoura commented on Dec 29, 2017

    @sergiomarqmoura

    @hannesa2 could you build it in the end?

  14. hannesa2 commented on Dec 29, 2017

    @hannesa2
    ContributorAuthor

    sorry no, even fork https://github.com/10imaging/opencv with command build.sh shows me

    [ 98%] Generating src/org/opencv/engine/OpenCVEngineInterface.aidl
    [ 98%] Generating OpenCV Android library project. SDK target: lib_target_sdk_target-NOTFOUND


    The "android" command is deprecated.
    For manual SDK, AVD, and project management, please use Android Studio.
    For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager


    Invalid or unsupported command "--silent create lib-project --path /Users/hannes/git/openCV/opencv/build/android/debug/arm7 --target lib_target_sdk_target-NOTFOUND --name OpenCV --package org.opencv"

    If someone knows how to fix, we should see it in main repo not in any fork.

  15. mshabunin commented on Dec 29, 2017

    @mshabunin
    Contributor

    @hannesa2 , make sure you have set ANDROID_SDK and ANDROID_NDK environment variables correctly. Please attach the output of your script here so that someone could take a look at the details.

  16. victorv commented on Jul 11, 2018

    @victorv

    @hannesa2 I fixed this by always using older tools but that is a hassel so I am writing a custom script to handle creating the library on the command line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: build/installplatform: androidquestion (invalid tracker)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions