Configuring the Cross Compilation Environment

If the OS architecture in the development environment differs from that in the operating environment, you need to use a cross compiler and library files of the operating environment's architecture to perform compilation in the development environment. In this way, the compiled executable file can be executed in the operating environment.

For example, if the runtime environment is an edge device and you are using an x86 server (or PC) to build the development environment, you must use a cross-compilation tool and aarch64-architecture library files for compilation.

Currently, compilation is supported using either the cross-compilation tools provided in the CANN Toolkit package or the g++ cross-compilers supported on Linux. For supported OSs (e.g., openEuler, Ubuntu), you can directly use the cross-compilation tools bundled with the CANN Toolkit package. For unsupported OSs and other Ascend AI Processors, you must manually install the appropriate g++ cross-compiler. For details, see Table 1.

Table 1 Cross compiler installation

Development Environment Architecture

Operating Environment Architecture

Compilation Environment Configuration

x86_64

AArch64

  • g++ cross compiler: Run the aarch64-linux-gnu-g++ --version command in the development environment as the installation user of the software package to check whether the g++ cross compiler has been installed. If it has been installed, skip this step.

    An example of the installation command is as follows. Run the command based on the actual situation. If you install the dependency as the root user, delete sudo from the command.

    sudo apt-get install g++-aarch64-linux-gnu
  • Path of the cross-compiler in the Toolkit (the default installation path of a non-root user is used as an example): ${HOME}/Ascend/cann/toolkit/toolchain/hcc/bin
  • Path of the library file of the AArch64 architecture (the default installation path of a non-root user is used as an example): ${HOME}/Ascend/cann/runtime/lib64/stub/aarch64