android ncnn

1、下载解压ndk

wget https://dl.google.com/android/repository/android-ndk-r17b-linux-x86_64.zip
unzip android-ndk-r17b-linux-x86_64.zip

2、设置ndk环境变量

export NDK_ROOT="/home/Your Name/android-ndk-r17b"

检测:

echo $NDK_ROOT    看输出

 

3、安装cmake

wget https://cmake.org/files/v3.11/cmake-3.11.2.tar.gz
tar -zxvf cmake-3.11.2.tar.gz
cd cmake-3.11.2
./bootstrap
make
make install
检测:cmake --version

cmake卸载:sudo apt-get autoremove cmake

 

4、下载ncnn

git clone https://github.com/Tencent/ncnn.git

# 进入到ncnn源码根目录下
cd ncnn
# 创建一个新的文件夹
mkdir -p build-android-armv7
# 进入到该文件夹中
cd build-android-armv7
# 执行编译命令
cmake -DCMAKE_TOOLCHAIN_FILE=/home/Your name/android-ndk-r17b/build/cmake/android.toolchain.cmake \
-DANDROID_ABI="armeabi-v7a" -DANDROID_ARM_NEON=ON \
-DANDROID_PLATFORM=android-14 ..
# 这里笔者使用4个行程并行编译
make -j4
make install

编译完成,会在build-android-armv7目录下生成一个install文件夹:

include :调用ncnn所需的头文件,该文件夹会存放在Android项目的src/main/cpp目录下;
lib 编译得到的ncnn库libncnn.a,之后会存放在Android项目的src/main/jniLibs/armeabi-v7a/libncnn.a

android ncnn

上一篇:实现移动端1像素线--stylus


下一篇:8.0之后 java.lang.SecurityException: Permission Denial: null asks to run as user 864 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERA