cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
seetalpot
Visitor
Visitor
388 Views
Registered: ‎06-17-2021

Vitis -lxilinxopencl error

I have installed Vitis from the following website:
 
While trying to compile a Vitis example in the downloaded repository "/tools/Xilinx/Vitis/2020.3/
examples/vadd" (without any modification), I have faced the following issue:
 

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$ sudo make -f vitis.mk host

g++  -L/lib/ -lxilinxopencl -lrt -pthread vadd.o -o vadd 

/usr/bin/ld: cannot find -lxilinxopencl

collect2: error: ld returned 1 exit status

../common/common.mk:120: recipe for target 'vadd' failed

make: *** [vadd] Error 1

 
The following link hints at setting the "LIBRARY_PATHenvironment variable to "/usr/lib/x86_64-linux-gnu", to resolve such issues. However, even after setting this variable, the linker error persists (snapshot attached): 
 
I have also tried 
1. Setting the "LD_LIBRARY_PATHenvironment variable to "/usr/lib/x86_64-linux-gnu" as well as 
2. "sudo ln -s /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 /usr/lib/libOpenCL.so" as suggested below, yet the same error persists.  
 
Please help!
 
Best Regards,
Seetal
0 Kudos
5 Replies
kmorris
Xilinx Employee
Xilinx Employee
316 Views
Registered: ‎01-11-2011

Hi Seetal, have you installed XRT alongside your Vitis install? Normally for embedded devices it wouldn't be necessary as it is included as part of the common images/sysroots, but for this particular example it doesn't use these files. The library it is looking for is included as part of this, so installing XRT and sourcing the settings script should point to the missing library. You can download XRT from here, you can pick the 2020.2 version and any device as the XRT install version will be the same (you won't need any of the other files presented, just the XRT package).

-------------------------------------------------------------------------
Please don’t forget to reply, kudo, and accept as solution!
-------------------------------------------------------------------------
0 Kudos
seetalpot
Visitor
Visitor
286 Views
Registered: ‎06-17-2021

Hi Morris,

Thanks for the suggestion. After installing the 2020.2.1 XRT, the "-lxilinxopencl" issue disappeared but I have noticed the following "undefined reference" issues. Please suggest: 

 

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$ sudo make -f vitis.mk host

g++ vadd.cpp -o vadd

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_device_id*>::retain(_cl_device_id*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP13_cl_device_idE6retainES3_[_ZN2cl6detail16ReferenceHandlerIP13_cl_device_idE6retainES3_]+0x14): undefined reference to `clRetainDevice'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_device_id*>::release(_cl_device_id*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP13_cl_device_idE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP13_cl_device_idE7releaseES3_]+0x14): undefined reference to `clReleaseDevice'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_context*>::release(_cl_context*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP11_cl_contextE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP11_cl_contextE7releaseES3_]+0x14): undefined reference to `clReleaseContext'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_command_queue*>::release(_cl_command_queue*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP17_cl_command_queueE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP17_cl_command_queueE7releaseES3_]+0x14): undefined reference to `clReleaseCommandQueue'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_mem*>::retain(_cl_mem*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP7_cl_memE6retainES3_[_ZN2cl6detail16ReferenceHandlerIP7_cl_memE6retainES3_]+0x14): undefined reference to `clRetainMemObject'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_mem*>::release(_cl_mem*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP7_cl_memE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP7_cl_memE7releaseES3_]+0x14): undefined reference to `clReleaseMemObject'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_program*>::release(_cl_program*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP11_cl_programE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP11_cl_programE7releaseES3_]+0x14): undefined reference to `clReleaseProgram'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_kernel*>::release(_cl_kernel*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP10_cl_kernelE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP10_cl_kernelE7releaseES3_]+0x14): undefined reference to `clReleaseKernel'

/tmp/cc47LCk1.o: In function `cl::detail::ReferenceHandler<_cl_event*>::release(_cl_event*)': vadd.cpp:(.text._ZN2cl6detail16ReferenceHandlerIP9_cl_eventE7releaseES3_[_ZN2cl6detail16ReferenceHandlerIP9_cl_eventE7releaseES3_]+0x14): undefined reference to `clReleaseEvent'

/tmp/cc47LCk1.o: In function `cl::Platform::getInfo(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator >*) const': vadd.cpp:(.text._ZNK2cl8Platform7getInfoEjPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZNK2cl8Platform7getInfoEjPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x24): undefined reference to `clGetPlatformInfo'

/tmp/cc47LCk1.o: In function `cl::Platform::getDevices(unsigned long, std::vector<cl::Device, std::allocator >*) const': vadd.cpp:(.text._ZNK2cl8Platform10getDevicesEmPSt6vectorINS_6DeviceESaIS2_EE[_ZNK2cl8Platform10getDevicesEmPSt6vectorINS_6DeviceESaIS2_EE]+0x68): undefined reference to `clGetDeviceIDs' vadd.cpp:(.text._ZNK2cl8Platform10getDevicesEmPSt6vectorINS_6DeviceESaIS2_EE[_ZNK2cl8Platform10getDevicesEmPSt6vectorINS_6DeviceESaIS2_EE]+0xe2): undefined reference to `clGetDeviceIDs'

/tmp/cc47LCk1.o: In function `cl::Platform::get(std::vector<cl::Platform, std::allocator >*)': vadd.cpp:(.text._ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE[_ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE]+0x52): undefined reference to `clGetPlatformIDs' vadd.cpp:(.text._ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE[_ZN2cl8Platform3getEPSt6vectorIS0_SaIS0_EE]+0xc2): undefined reference to `clGetPlatformIDs'

/tmp/cc47LCk1.o: In function `cl::Context::Context(cl::Device const&, long*, void (*)(char const*, void const*, unsigned long, void*), void*, int*)': vadd.cpp:(.text._ZN2cl7ContextC2ERKNS_6DeviceEPlPFvPKcPKvmPvES9_Pi[_ZN2cl7ContextC5ERKNS_6DeviceEPlPFvPKcPKvmPvES9_Pi]+0x72): undefined reference to `clCreateContext'

/tmp/cc47LCk1.o: In function `cl::Buffer::Buffer(cl::Context const&, unsigned long, unsigned long, void*, int*)': vadd.cpp:(.text._ZN2cl6BufferC2ERKNS_7ContextEmmPvPi[_ZN2cl6BufferC5ERKNS_7ContextEmmPvPi]+0x62): undefined reference to `clCreateBuffer'

/tmp/cc47LCk1.o: In function `cl::Program::Program(cl::Context const&, std::vector<cl::Device, std::allocator > const&, std::vector<std::pair, std::allocator<std::pair > > const&, std::vector<int, std::allocator >*, int*)': vadd.cpp:(.text._ZN2cl7ProgramC2ERKNS_7ContextERKSt6vectorINS_6DeviceESaIS5_EERKS4_ISt4pairIPKvmESaISD_EEPS4_IiSaIiEEPi[_ZN2cl7ProgramC5ERKNS_7ContextERKSt6vectorINS_6DeviceESaIS5_EERKS4_ISt4pairIPKvmESaISD_EEPS4_IiSaIiEEPi]+0x343): undefined reference to `clCreateProgramWithBinary'

/tmp/cc47LCk1.o: In function `cl::Kernel::Kernel(cl::Program const&, char const*, int*)': vadd.cpp:(.text._ZN2cl6KernelC2ERKNS_7ProgramEPKcPi[_ZN2cl6KernelC5ERKNS_7ProgramEPKcPi]+0x52): undefined reference to `clCreateKernel'

/tmp/cc47LCk1.o: In function `cl::CommandQueue::CommandQueue(cl::Context const&, cl::Device const&, unsigned long, int*)': vadd.cpp:(.text._ZN2cl12CommandQueueC2ERKNS_7ContextERKNS_6DeviceEmPi[_ZN2cl12CommandQueueC5ERKNS_7ContextERKNS_6DeviceEmPi]+0x74): undefined reference to `clCreateCommandQueue'

/tmp/cc47LCk1.o: In function `cl::CommandQueue::enqueueMapBuffer(cl::Buffer const&, unsigned int, unsigned long, unsigned long, unsigned long, std::vector<cl::Event, std::allocator > const*, cl::Event*, int*) const': vadd.cpp:(.text._ZNK2cl12CommandQueue16enqueueMapBufferERKNS_6BufferEjmmmPKSt6vectorINS_5EventESaIS5_EEPS5_Pi[_ZNK2cl12CommandQueue16enqueueMapBufferERKNS_6BufferEjmmmPKSt6vectorINS_5EventESaIS5_EEPS5_Pi]+0xe0): undefined reference to `clEnqueueMapBuffer'

/tmp/cc47LCk1.o: In function `cl::CommandQueue::enqueueUnmapMemObject(cl::Memory const&, void*, std::vector<cl::Event, std::allocator > const*, cl::Event*) const': vadd.cpp:(.text._ZNK2cl12CommandQueue21enqueueUnmapMemObjectERKNS_6MemoryEPvPKSt6vectorINS_5EventESaIS6_EEPS6_[_ZNK2cl12CommandQueue21enqueueUnmapMemObjectERKNS_6MemoryEPvPKSt6vectorINS_5EventESaIS6_EEPS6_]+0xb6): undefined reference to `clEnqueueUnmapMemObject'

/tmp/cc47LCk1.o: In function `cl::CommandQueue::enqueueMigrateMemObjects(std::vector<cl::Memory, std::allocator > const&, unsigned long, std::vector<cl::Event, std::allocator > const*, cl::Event*) const': vadd.cpp:(.text._ZNK2cl12CommandQueue24enqueueMigrateMemObjectsERKSt6vectorINS_6MemoryESaIS2_EEmPKS1_INS_5EventESaIS7_EEPS7_[_ZNK2cl12CommandQueue24enqueueMigrateMemObjectsERKSt6vectorINS_6MemoryESaIS2_EEmPKS1_INS_5EventESaIS7_EEPS7_]+0x169): undefined reference to `clEnqueueMigrateMemObjects'

/tmp/cc47LCk1.o: In function `cl::CommandQueue::enqueueTask(cl::Kernel const&, std::vector<cl::Event, std::allocator > const*, cl::Event*) const': vadd.cpp:(.text._ZNK2cl12CommandQueue11enqueueTaskERKNS_6KernelEPKSt6vectorINS_5EventESaIS5_EEPS5_[_ZNK2cl12CommandQueue11enqueueTaskERKNS_6KernelEPKSt6vectorINS_5EventESaIS5_EEPS5_]+0xae): undefined reference to `clEnqueueTask'

/tmp/cc47LCk1.o: In function `cl::CommandQueue::finish() const': vadd.cpp:(.text._ZNK2cl12CommandQueue6finishEv[_ZNK2cl12CommandQueue6finishEv]+0x17): undefined reference to `clFinish' /tmp/cc47LCk1.o: In function `std::enable_if<!std::is_pointer::value, int>::type cl::Kernel::setArg(unsigned int, cl::Buffer const&)': vadd.cpp:(.text._ZN2cl6Kernel6setArgINS_6BufferEEENSt9enable_ifIXntsrSt10is_pointerIT_E5valueEiE4typeEjRKS5_[_ZN2cl6Kernel6setArgINS_6BufferEEENSt9enable_ifIXntsrSt10is_pointerIT_E5valueEiE4typeEjRKS5_]+0x43): undefined reference to `clSetKernelArg'

/tmp/cc47LCk1.o: In function `std::enable_if<!std::is_pointer::value, int>::type cl::Kernel::setArg(unsigned int, int const&)': vadd.cpp:(.text._ZN2cl6Kernel6setArgIiEENSt9enable_ifIXntsrSt10is_pointerIT_E5valueEiE4typeEjRKS4_[_ZN2cl6Kernel6setArgIiEENSt9enable_ifIXntsrSt10is_pointerIT_E5valueEiE4typeEjRKS4_]+0x43): undefined reference to `clSetKernelArg'

/tmp/cc47LCk1.o: In function `int cl::Device::getInfo<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator >*) const': vadd.cpp:(.text._ZNK2cl6Device7getInfoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEijPT_[_ZNK2cl6Device7getInfoINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEijPT_]+0x24): undefined reference to `clGetDeviceInfo' collect2: error: ld returned 1 exit status : recipe for target 'vadd' failed make: *** [vadd] Error 1

Best Regards,

Seetal

0 Kudos
kmorris
Xilinx Employee
Xilinx Employee
265 Views
Registered: ‎01-11-2011

Can you make sure that the LD_LIBRARY_PATH/LIBRARY_PATH environment variables show the XRT library locations before the other areas. Also you could try changing the order of the library call to the end of the list, so the -lxilinxopencl is at the end of the g++ command.

-------------------------------------------------------------------------
Please don’t forget to reply, kudo, and accept as solution!
-------------------------------------------------------------------------
0 Kudos
seetalpot
Visitor
Visitor
236 Views
Registered: ‎06-17-2021

Hi Morris,

 

Thanks for the suggestion. After setting LD_LIBRARY_PATH/LIBRARY_PATH environment variables to XRT library locations and placing "-lxilinxopencl" to the end of the g++ command, the error persisted:

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$  export LD_LIBRARY_PATH=/opt/xilinx/xrt:$LD_LIBRARY_PATH

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$ export LIBRARY_PATH=/opt/xilinx/xrt:$LIBRARY_PATH

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$ sudo make -f vitis.mk host

g++ -g -Wall -DFPGA_DEVICE -DC_KERNEL  -DTARGET_DEVICE=\"xilinx_u200_xdma_201920_1\" -I/include/ -c vadd.cpp -o vadd.o

g++  vadd.o -o vadd -lxilinxopencl

/usr/bin/ld: cannot find -lxilinxopencl

collect2: error: ld returned 1 exit status

../common/common.mk:128: recipe for target 'vadd' failed

make: *** [vadd] Error 1

 

I have attached the "common/common.mk" and "vadd/vitis.mk" files for your reference. Please help!

 

Best Regards,

Seetal

 

0 Kudos
seetalpot
Visitor
Visitor
187 Views
Registered: ‎06-17-2021

Hi Morris,

 

If I replace "lxilinxopencl" with "lOpenCL", it works:

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$ sudo make -f vitis.mk host

g++ -g -Wall -DFPGA_DEVICE -DC_KERNEL  -DTARGET_DEVICE=\"xilinx_u200_xdma_201920_1\" -I/include/ -c vadd.cpp -o vadd.o

g++  vadd.o -o vadd -lOpenCL

spotlur2@bletchleypark:/tools/Xilinx/Vitis/2020.3/examples/vadd$ 

 

Please suggest how to fix the "-lxilinxopencl" issue.

 

Best Regards,

Seetal

0 Kudos