当前位置:   article > 正文

ncnn | windows 下编译ncnn android库_windows ncnn android编译

windows ncnn android编译

软件环境

  • ncnn
  • vulkan(option)
  • cmake
  • android ndk

编译

主要编译两个架构和是否加vulkan.
在ncnn 同级目录新建 build_android.bat,写入下面内容。编译脚本在官方基础上加下面语句。

set ANDROID_NDK= your android ndk root # eg C:/android-ndk-r20
 -G "Unix Makefiles" 
 -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%/prebuilt/windows-x86_64/bin/make.exe" 
  • 1
  • 2
  • 3
  • armeabi-v7a
    • no vulkan
cd ncnn 
# cmake option NCNN_VULKAN for enabling vulkan
set ANDROID_NDK= your android ndk root # eg C:/android-ndk-r20
mkdir -p build-android-armv7
cd build-android-armv7
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%/prebuilt/windows-x86_64/bin/make.exe"  -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON -DANDROID_PLATFORM=android-21 ..
cmake --build .
cmake --build . --target install
cd ../../
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • vulkan
    • vulkan
cd ncnn 
# cmake option NCNN_VULKAN for enabling vulkan
set ANDROID_NDK= your android ndk root # eg C:/android-ndk-r20
mkdir -p build-android-armv7
cd build-android-armv7
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%/prebuilt/windows-x86_64/bin/make.exe"  -DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON -DANDROID_PLATFORM=android-24 -DNCNN_VULKAN=ON ..
cmake --build .
cmake --build . --target install
cd ../../
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • aarch64 library
    • no vulkan
cd ncnn
# cmake option NCNN_VULKAN for enabling vulkan
set ANDROID_NDK=your android ndk root # eg C:/android-ndk-r20
mkdir -p build-android-aarch64
cd build-android-aarch64

cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%/prebuilt/windows-x86_64/bin/make.exe" -DANDROID_ABI="arm64-v8a" -DANDROID_ARM_NEON=ON -DANDROID_PLATFORM=android-21 ..
cmake --build .
cmake --build . --target install
cd ../../
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

vulkan

cd ncnn
# cmake option NCNN_VULKAN for enabling vulkan
set ANDROID_NDK=your android ndk root # eg C:/android-ndk-r20
mkdir -p build-android-aarch64
cd build-android-aarch64
# if you want to enable vulkan, platform api version >= android-24 is needed
cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK%/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%ANDROID_NDK%/prebuilt/windows-x86_64/bin/make.exe" -DANDROID_ABI="arm64-v8a" -DANDROID_ARM_NEON=ON -DANDROID_PLATFORM=android-24 -DNCNN_VULKAN=ON ..

cmake --build .
cmake --build . --target install
cd ../../
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/298020
推荐阅读
相关标签
  

闽ICP备14008679号