Compiling and Linking for x86 - 2024.2 English - UG1700

Data Center Acceleration Using Vitis User Guide (UG1700)

Document ID
UG1700
Release Date
2025-01-15
Version
2024.2 English
Tip: Set up the command shell or window as described in Setting Up the Vitis Environment in the Data Center Acceleration using Vitis (UG1700) 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

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)