g++ ... -c <source_file1> <source_file2> ... <source_fileN>
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.
-I../libs/xcl2include 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 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
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