Compiling and Linking Host Code for Linux - 2023.1 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2023-06-23
Version
2023.1 English

You can compile the embedded application by following the typical cross-compilation flow for the Arm Cortex-A72 processor.

In order to compile and link the host application to run on the Versal architecture board you must use the Vitis 2023.1 software.

The expectation is that you have completed the following setup:

  1. Install the Vitis 2023.1 software. The Vitis release includes all the embedded base platforms, including the VCK190 base platforms.
  2. In addition, ensure you have downloaded the Common Images for Embedded Vitis Platforms from this link https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-platforms/2023-1.html

    The common image package contains a prebuilt Linux kernel and root file system that can be used with the Versal architecture board for embedded design development using Vitis.

  3. Unzip the Versal common image package.
  4. In a Bash shell, run the following script:

    /Common Images Dir/xilinx-versal-common-v2023.1/environment-setup-cortexa72-cortexa53-xilinx-linux

    This script sets up the SDKTARGETSYSROOT and CXX variables.

    If the script is not present, you must run /Common Images Dir/xilinx-versal-common-v2023.1/sdk.sh.

Now you are ready to compile and link the host application.

Compiling the Host Application

Compiling the PS application uses the CXX variable. The following is an example command for compiling the PS application:
$CXX -std=c++17 -I${SDKTARGETSYSROOT}/usr/include/xrt/ -g -Wall -c -fmessage-length=0 -o host.o host.cpp 

Many of the options in the preceding command are standard and can be found in a description of the g++ command. The more important options are listed as follows.

  • -std=c++17
  • -I${SDKTARGETSYSROOT}/usr/include/xrt/
  • -o host.o host.cpp

Linking the Host Application

Linking the PS application uses the CXX variable. The following is an example command for linking the PS application:
$CXX -lxrt_coreutil -o host.exe host.o

xrt_coreutil: Required library for linking for XRT API.

For compilation and linking for host code contains ADF API, see Compiling the Embedded Application for the Cortex-A72 Processor .