Compiling and Linking Host Code for Linux - 2023.2 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2023-12-04
Version
2023.2 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.2 software.

The expectation is that you have completed the following setup:

  1. Install the Vitis 2023.2 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-2.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.2/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.2/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 in the Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393).

Important: The steps to integrate the host code with the AI Engine graph application and the PL kernels into the hardware platform requires running the v++ --package command. Details on building and running the Versal system using the Vitis tool flow is described in Building and Running the System in Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393).