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 edge device 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-compiler provided in the development kit and the G++ cross-compiler supported on Linux can be used for compilation. The cross-compiler provided in the development kit can be used for OSs (such as openEuler and Ubuntu) adapted to CANN. For OSs not adapted to CANN and other Ascend AI Processors), install the 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 development kit (using the default installation path of a non-root user as an example): ${HOME}/Ascend/cann/toolkit/toolchain/hcc/bin
  • Path of the library file of the AArch64 architecture (using the default installation path of a non-root user as an example): ${HOME}/Ascend/cann/runtime/lib64/stub/aarch64