<spanid="build-the-inference-library"></span><h3>Build the Inference Library<aclass="headerlink"href="#build-the-inference-library"title="Permalink to this headline">¶</a></h3>
<spanid="build-the-inference-library"></span><h3>Build the Inference Library<aclass="headerlink"href="#build-the-inference-library"title="Permalink to this headline">¶</a></h3>
<p>Android NDK includes everything we need to build the <aclass="reference external"href="https://developer.android.com/ndk/guides/standalone_toolchain.html"><em>standalone toolchain</em></a>, which in then used to build PaddlePaddle for Android. (We plan to remove the intermediate stage of building the standalone toolchain in the near future.)</p>
<p>Android NDK includes everything we need to build the <aclass="reference external"href="https://developer.android.com/ndk/guides/standalone_toolchain.html"><em>standalone toolchain</em></a>, which in then used to build PaddlePaddle for Android. (We plan to remove the intermediate stage of building the standalone toolchain in the near future.)</p>
<ul>
<ulclass="simple">
<li><pclass="first">To build the standalone toolchain for <codeclass="docutils literal"><spanclass="pre">armeabi-v7a</span></code> and Android API level 21:</p>
<li>To build the standalone toolchain for <codeclass="docutils literal"><spanclass="pre">armeabi-v7a</span></code> and Android API level 21:</li>
<p>The generated standalone toolchain will be in <codeclass="docutils literal"><spanclass="pre">your/path/to/arm_standalone_toolchain</span></code>.</p>
<p>The generated standalone toolchain will be in <codeclass="docutils literal"><spanclass="pre">your/path/to/arm_standalone_toolchain</span></code>.</p>
</li>
<ulclass="simple">
<li><pclass="first">To build the standalone toolchain for <codeclass="docutils literal"><spanclass="pre">arm64-v8a</span></code> and Android API level 21:</p>
<li>To build the standalone toolchain for <codeclass="docutils literal"><spanclass="pre">arm64-v8a</span></code> and Android API level 21:</li>
<p>The generated standalone toolchain will be in <codeclass="docutils literal"><spanclass="pre">your/path/to/arm64_standalone_toolchain</span></code>.</p>
<p>The generated standalone toolchain will be in <codeclass="docutils literal"><spanclass="pre">your/path/to/arm64_standalone_toolchain</span></code>.</p>
<spanid="cross-compiling-arguments"></span><h3>Cross-Compiling Arguments<aclass="headerlink"href="#cross-compiling-arguments"title="Permalink to this headline">¶</a></h3>
<spanid="cross-compiling-arguments"></span><h3>Cross-Compiling Arguments<aclass="headerlink"href="#cross-compiling-arguments"title="Permalink to this headline">¶</a></h3>
执行上述`docker run`命令时,容器默认执行[paddle/scripts/docker/build_android.sh](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build_android.sh)脚本。该脚本中记录了交叉编译Android版PaddlePaddle库常用的CMake配置,并且会根据`ANDROID_ABI`和`ANDROID_API`自动构建独立工具链、进行编译和安装。由于arm64架构要求Android API不小于21。因此当`ANDROID_ABI=arm64-v8a`,`ANDROID_API<21`时,Docker容器中将默认使用`Android API 21`的编译工具链。用户可以参考下文[配置交叉编译参数](#配置交叉编译参数)章节,根据个人的需求修改定制Docker容器所执行的脚本。编译安装结束之后,PaddlePaddle的C-API库将被安装到`$PWD/install_android`目录,所依赖的第三方库同时也被安装到`$PWD/install_android/third_party`目录。
执行上述`docker run`命令时,容器默认执行[paddle/scripts/docker/build_android.sh](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/scripts/docker/build_android.sh)脚本。该脚本中记录了交叉编译Android版PaddlePaddle库常用的CMake配置,并且会根据`ANDROID_ABI`和`ANDROID_API`自动构建独立工具链、进行编译和安装。由于arm64架构要求Android API不小于21。因此当`ANDROID_ABI=arm64-v8a`,`ANDROID_API<21`时,Docker容器中将默认使用`Android API 21`的编译工具链。用户可以参考下文[配置交叉编译参数](#配置交叉编译参数)章节,根据个人的需求修改定制Docker容器所执行的脚本。编译安装结束之后,PaddlePaddle的C-API库将被安装到`$PWD/install_android`目录,所依赖的第三方库同时也被安装到`$PWD/install_android/third_party`目录。