Android compile MNN

Refer to the official MNN document ubuntu environment to record the compilation process
Compilation environment : Ubuntu 20.04.2 LTS NDK: android-ndk-r22b
MNN environment requirements
● cmake (version 3.10 or above is recommended),
● protobuf (version 3.0 or above)
● gcc ( Use 4.9 or above)

1. Download NDK https://developer.android.google.cn/ndk/downloads?hl=zh_cn
2. Download MNN source code

git command to download or download the compressed package to decompress it yourself

 git clone https://github.com/Tencent/ncnn.git
3. compile
#进入编译目录
cd {
    
    mnn-root-dir}/project/android
#编译armv7动态库
mkdir build_32 && cd build_32 && ../build_32.sh
#编译armv8动态库:
mkdir build_64 && cd build_64 && ../build_64.sh
  • Normally compile the dynamic library armv7 in {mnn-root-dir}/project/android/build_32, armv8 is the same.
    insert image description here
  • Header file

    note: There is a problem with the compilation here. The environment variable has been set, but the compilation chain of ndk has not been found, resulting in the failure to compile. There is no way to do it
    insert image description here
    later, but to directly specify the position of the current compilation chain in the script file
    to modify The script file (build_32.sh, build_64.sh)
    changes the location of the compilation chain behind DCMAKE_TOOLCHAIN_FILE= to the location of its own ndk compilation chain, for example, mine is /home/moyihen/Desktop/android-ndk-r22b/build/cmake/android .toolchain.cmake
    Before modification:
    insert image description here
    After modification: After
    insert image description here
    modification, it can be compiled normally.

For the integrated deployment model, please refer to https://blog.csdn.net/qq_35193677/article/details/126526770 .

Guess you like

Origin blog.csdn.net/qq_35193677/article/details/126424105