The host program (host.exe
), is
cross-compiled for an Arm processor, and linked
using the following two step process:
- Compile the host.cpp into an
object file (.o) using the GNU Arm cross-compiler version of
g++
:Note:aarch64
is used for Zynq® UltraScale+™ (A53) and Versal™ (A72) devices.aarch32
is used for Zynq-7000 SoC (A9) and the tool chain is in a different location.$XILINX_VITIS/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ \ -D__USE_XOPEN2K8 -I$SYSROOT/usr/include/xrt -I$XILINX_VIVADO/include \ -I$SYSROOT/usr/include -c -fmessage-length=0 -std=c++14 \ --sysroot=$SYSROOT -o src/host.o ../src/host.cpp
- Link the object file with required libraries to build the executable
application.
$XILINX_VITIS/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ \ -o host.exe src/host.o -lxilinxopencl -lpthread -lrt -lstdc++ -lgmp -lxrt_core \ -L$SYSROOT/usr/lib/ --sysroot=$SYSROOT
When compiling the application for use with an embedded process, you must specify the sysroot for the application. The sysroot is part of the platform where the basic system root file structure is defined, and is installed as described in Installing Embedded Platforms .
$SYSROOT
environment variable that
must be used to specify the location of the sysroot for your embedded platform. The following are key elements to compiling the host code for an edge platform:
- Compilation
-
- The cross compiler needed is the
aarch64-linux-gnu-g++
found in the Vitis installation hierarchy. - The required include paths are:
- $SYSROOT/usr/include
- $SYSROOT/usr/include/xrt
- $XILINX_VIVADO/include
- The cross compiler needed is the
- Linking
-
- $SYSROOT/usr/lib: Library paths location.
- xilinxopencl: XRT required library.
- pthread: XRT required library.
- rt: XRT required library.
- stdc++: XRT required library.
- gmp: XRT required library.
- xrt_core: XRT required library.
Building XRT Native API
XRT provides a native XRT API for C, C++, and Python, as described
on the XRT site at https://xilinx.github.io/XRT/2020.2/html/xrt_native_apis.html. To use the native XRT API, the host
application must link with the xrt_coreutil
library instead of the xlinxopencl
library. The
command line uses a few different settings as shown in the following example for
compilation and linking:
$XILINX_VITIS/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ -c \
-D__USE_XOPEN2K8 -I$SYSROOT/usr/include/xrt -I$XILINX_VIVADO/include \
-I$SYSROOT/usr/include -fmessage-length=0 -std=c++14 --sysroot=$SYSROOT \
-o src/host.o ../src/host.cpp
$XILINX_VITIS/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ -l \
-lxrt_coreutil -lpthread -lrt -lstdc++ -lgmp -lxrt_core -L$SYSROOT/usr/lib/ \
--sysroot=$SYSROOT -o host.exe src/host.o