Compiling and Linking for x86 - 2020.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
Release Date
2020.2 English
Tip: Set up the command shell or window as described in Setting Up the Vitis Environment prior to running the tools.
Each source file of the host application is compiled into an object file (.o) using the g++ compiler.
g++ ... -c <source_file1> <source_file2> ... <source_fileN>
The generated object files (.o) are linked with the Xilinx Runtime (XRT) shared library to create the executable host program. Linking is performed using the -l option.
g++ ... -l <object_file1.o> ... <object_fileN.o>

Compiling and linking for x86 follows the standard g++ flow. The only requirement is to include the XRT header files and link the XRT shared libraries.

When compiling the source code, the following g++ options are required:

  • -I$XILINX_XRT/include/: XRT include directory.
  • -I$XILINX_VIVADO/include: Vivado tools include directory.
  • -std=c++11: Define the C++ language standard.

When linking the executable, the following g++ options are required:

  • -L$XILINX_XRT/lib/: Look in XRT library.
  • -lOpenCL: Search the named library during linking.
  • -lpthread: Search the named library during linking.
  • -lrt: Search the named library during linking.
  • -lstdc++: Search the named library during linking.
Note: In the Vitis Examples you may see the addition of xcl2.cpp source file, and the -I../libs/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 own code.

Building XRT Native API

XRT provides a native XRT API for C, C++, and Python, as described on the XRT site at To use the native XRT API, the host application must link with the xrt_coreutil library. The command line uses a few different settings as shown in the following example, which combines compilation and linking:

g++ -g -std=c++14 -I$XILINX_XRT/include -L$XILINX_XRT/lib -lxrt_coreutil -lpthread \
-o host.exe host.cpp 
Important: The XRT API requires the use of -std=c++14.