Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎11-10-2020

undefined reference to 'xclOpenContext'


I am trying to customize an example that needs to access registers through axi-lite ports. I added codes like: 

    xclOpenContext(handle, xclbinId, cuidx, false);
    xclRegRead(handle, cuidx, scalar_offset, &val);
        std::cout << "\nThe register value that is read : " << val
            << std::endl;
    xclCloseContext(handle, xclbinId, cuidx);

 But when I tried to make, the error is:

g++ -I/opt/xilinx/xrt/include/ -I/tools/Xilinx/Vivado/2020.1/include/ -Wall -O0 -g -std=c++11 -L/opt/xilinx/xrt/lib/ -lOpenCL -lpthread -lrt -lstdc++ -I/home/rcl/Vitis_Accel_Examples/common/includes/xcl2/ -o 'host' '../src/host/host_step_reg.cpp' -lOpenCL -luuid
/tmp/ccb3GU1J.o: In function `main':
/home/rcl/Vitis-Tutorials/docs/mixing-c-rtl-kernels/reference-files/run_reg_test/../src/host/host_step_reg.cpp:247: undefined reference to `xcl::Ext::getComputeUnitInfo'
/home/rcl/Vitis-Tutorials/docs/mixing-c-rtl-kernels/reference-files/run_reg_test/../src/host/host_step_reg.cpp:258: undefined reference to `xclOpenContext'
/home/rcl/Vitis-Tutorials/docs/mixing-c-rtl-kernels/reference-files/run_reg_test/../src/host/host_step_reg.cpp:259: undefined reference to `xclRegRead'
/home/rcl/Vitis-Tutorials/docs/mixing-c-rtl-kernels/reference-files/run_reg_test/../src/host/host_step_reg.cpp:262: undefined reference to `xclCloseContext'
collect2: error: ld returned 1 exit status
Makefile:47: recipe for target 'host' failed
make: *** [host] Error 1

I checked the xrt headers

xclOpenContext is declared in xrt.h, xclRegRead is declared in experimental/xrt-next.h

But in the Makefile, the xrt/include is already included and xrt/lib is already linked in the Makefile. I do not know why.

(I use vitis 2020.1, xrt 2.6.655 with deployment and development platform 201920_3)









0 Kudos
1 Reply
Xilinx Employee
Xilinx Employee
Registered: ‎01-11-2011

I see that you have included the paths for the header files as part of your compile command, but have you made sure to reference the appropriate files in your host code via the include?

As an example, the streaming register access example utilizes the functions you are trying to use, and you can compare the includes to the ones you have in your host code.


Please don’t forget to reply, kudo, and accept as solution!
0 Kudos