简体   繁体   中英

unable to build opencv for android

I am trying to build opencv pulled from github for android

I am running following command

cd ~/extProjects/opencv && cd build_android && cmake -DANDROID_SDK_TOOLS=~/Android/Sdk/tools -DANDROID_NDK=~/Android/Sdk/ndk/ -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=~/extProjects/opencv/platforms/android/android.toolchain.cmake -DANDROID_PLATFORM=android-32 -DINSTALL_CREATE_DISTRIB=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=./install ~/extProjects/opencv && make

NDK path is correct and here is the version ~/Android/Sdk/ndk/25.1.8937393 But I am getting following error

CMake Error at platforms/android/android.toolchain.cmake:628 (message):
  Could not find any working toolchain in the NDK.  Probably your Android NDK
  is broken.

Any suggestions where to look for and fix this?

Got it working after having to do additional defines

cd ~/extProjects/opencv && cd build_android && cmake -DANDROID_SDK_TOOLS=/your/home/path/Android/Sdk/build-tools -DANDROID_SDK_TOOLS_VERSION=33.0.1 -DANDROID_SDK=/your/home/path/Android/Sdk -DANDROID_NDK=~/Android/Sdk/ndk/25.1.8937393 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk/25.1.8937393/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-30 -DINSTALL_CREATE_DISTRIB=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install ~/extProjects/opencv && make

Also note for the android SDK path, giving "~" for home directory does not work

Compilation has started.. have to now see if I can get it work:|

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM