g++
compiler.
g++ ... -c <source_file1> <source_file2> ... <source_fileN>
-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.
The host application can be written in native C++ using the Xilinx Runtime (XRT) native C++ API or industry standard OpenCL™ 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:
g++ -g -std=c++14 -I$XILINX_XRT/include -L$XILINX_XRT/lib -o host.exe host.cpp \
-lxrt_coreutil -pthread
When compiling the source code, the following g++
options are required:
-
-I$XILINX_XRT/include/
: XRT include directory. -
-std=c++14
: Define the C++ language standard. Compiling host code with XRT native C++ API requires C++ standard with-std=c++14
or newer. However, on GCC versions older than 4.9.0, use-std=c++1y
instead.
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.
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 \
-lOpenCL -pthread
The only difference is the use of the OpenCL
library for the OpenCL API
in place of the xrt_coreutil
library for the XRT
native API.
-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
own code.