ncnn | 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" 
  • 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 ../../
  • 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 ../../
  • 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 ../../

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 ../../
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页