Compiling and Linking for x86 - 2023.2 English

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

Document ID
Release Date
2023.2 English
Tip: Set up the command shell or window as described in Setting Up the Vitis Environment prior to running the tools.

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. Each source file of the host application is compiled into an object file (.o) using the g++ compiler. The generated object files (.o) are linked with the Xilinx Runtime (XRT) shared library to create the executable host program using the g++ -l option.

The host application can be written in native C++ using the Xilinx Runtime (XRT) native C++ API. The required include files and libraries depend on the API your host application uses, and any specific requirements of your host code.

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:

$CXX -std=c++17 -O0 -g -Wall -c -I./src -o host.o sw/host.cpp

When compiling the source code using XRT native API, the following g++ options are required:

  • -std=c++17: Define the C++ language standard. Compiling host code with XRT native C++ API requires C++ standard with -std=c++17 or newer. However, on GCC versions older than 4.9.0, use -std=c++1y instead.
  • -I$XILINX_XRT/include/: XRT include directory
  • -I${XILINX_VITIS}/aietools/include: AI Engine Include directory
  • -I./src/aie: Include AI Engine graph and kernel source files

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

  • -L$XILINX_XRT/lib/: Look in XRT library.
  • -lxrt_coreutil: Search the named library during linking.
  • -pthread: Search the named library during linking.

Command to Link the Host Application Against Required XRT APIs and Generate the Executable:

g++ *.o -lxrt_coreutil -L${XILINX_XRT}/lib -o $(EXECUTABLE)


To use the ADF API, here is the command to compile the host application:

g++ -Wall -c -std=c++17 -Wno-int-to-pointer-cast -I${XILINX_XRT}/include \
-I./src/aie -I./ -I${XILINX_VITIS}/aietools/include \
-o aie_control_xrt.o ./Work/ps/c_rts/aie_control_xrt.cpp$
The following is the command to link the host application against required XRT APIs and generate the executable:
-ladf_api_xrt -L${XILINX_VITIS}/aietools/lib/lnx64.o