For embedded processor-based platforms, the host program (
host.exe), is cross-compiled and linked for an Arm processor using the GNU Arm cross-compiler version of
the following two step process:
aarch64 is used for
aarch32 is used for Zynq-7000 SoC
(A9) and the tool chain is in a different location.
- Compile the host.cpp into an
object file (.o):
$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
- Link the object file with required libraries to build the executable
$XILINX_VITIS/gnu/aarch64/lin/aarch64-linux/bin/aarch64-linux-gnu-g++ -l \ -lxrt_coreutil -lpthread -lrt -lstdc++ -lgmp -L$SYSROOT/usr/lib/ \ --sysroot=$SYSROOT -o host.exe src/host.o
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:
-std=c++14: Define the C++ language standard. Compiling host code with XRT native C++ API requires C++ standard with
-std=c++14or newer. However, on GCC versions older than 4.9.0, use
- -L$SYSROOT/usr/lib: Library paths location.
-lxrt_coreutil: Required library for use with the XRT native API.
-pthread: Required by XRT library for multithreading.
Building OpenCL API Host Code
g++ uses the following command line:
g++ -g -std=c++1y -I$XILINX_XRT/include -L$XILINX_XRT/lib -o host.exe host.cpp \
The only difference is the use of the
OpenCL library for the OpenCL API
in place of the
xrt_coreutil library for the XRT
-I../xcl2 include statement. These additions to the
host program and
g++ command provide access to
helper utilities used by the example code, but are generally not required for your