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.

If the operating environment is set up on an A200I A2 accelerator module (RC) or Atlas 500 A2 edge station and the development environment is set up on an x86 server (or PC), you need to use a cross compiler and library files of the AArch64 architecture to perform compilation in the development environment.

Currently, the cross compilation tool provided in the development kit and the g++ cross compilation tool supported by Linux can be used for compilation. The cross compilation tool provided in the development kit can be used for the OSs (such as openEuler and Ubuntu) that have been adapted to CANN, for OSs that are not adapted and other Ascend AI Processor. For example, the operating environment is A200 AI accelerator module (RC), you need to install the g++ cross compilation tool. 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.

    The following is an example of the installation command. (If you install the dependencies as the root user, delete sudo from the command.)

    1
    sudo apt-get install g++-aarch64-linux-gnu
    
  • Path of the cross compilation tool in the development kit (the default installation path of a non-root user is used as an example): ${HOME} /Ascend/ascend-toolkit/latest/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/ascend-toolkit/latest/runtime/lib64/stub/aarch64.