0

I am trying to reproduce the SAXPY routine in OpenCL from the URL

https://subscription.packtpub.com/book/application-development/9781849692342/1/ch01lvl1sec12/an-example-of-opencl-program

I am compiling according to the article with the command below. The OpenCL include files, exists just one folder up from the current with the name ../CL. I can verify that the libOpenCL.so exists in the specified folder /usr/lib/x86_64-linux-gnu.

$ ls -la /usr/lib/x86_64-linux-gnu/*OpenCL*
lrwxrwxrwx 1 root root    18 Jun  4 11:39 /usr/lib/x86_64-linux-gnu/libOpenCL.so -> libOpenCL.so.1.0.0
lrwxrwxrwx 1 root root    18 Jun  4 11:39 /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 -> libOpenCL.so.1.0.0
-rw-r--r-- 1 root root 35200 Mar 15  2014 /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0

gcc -I../ -L/usr/lib/x86_64-linux-gnu/ -lOpenCL saxpy.cpp -o saxpy

GCC is failing with the error below. According to my understanding, it seems it could not found the OpenCL library. What am I doing wrong here?

In file included from ../CL/cl.h:20:0,
                 from saxpy.cpp:6:
../CL/cl_version.h:22:104: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)
 #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
                                                                                                        ^
saxpy.cpp: In function 'int main()':
saxpy.cpp:60:36: warning: '_cl_command_queue* clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*)' is deprecated (declared at ../CL/cl.h:1906) [-Wdeprecated-declarations]
   cl_command_queue command_queue = clCreateCommandQueue(context, device_list[0], 0, &clStatus);
                                    ^
saxpy.cpp:60:94: warning: '_cl_command_queue* clCreateCommandQueue(cl_context, cl_device_id, cl_command_queue_properties, cl_int*)' is deprecated (declared at ../CL/cl.h:1906) [-Wdeprecated-declarations]
   cl_command_queue command_queue = clCreateCommandQueue(context, device_list[0], 0, &clStatus);
                                                                                              ^
/tmp/ccJUn6l3.o: In function `main':
saxpy.cpp:(.text+0xd7): undefined reference to `clGetPlatformIDs'
saxpy.cpp:(.text+0x105): undefined reference to `clGetPlatformIDs'
saxpy.cpp:(.text+0x135): undefined reference to `clGetDeviceIDs'
saxpy.cpp:(.text+0x16e): undefined reference to `clGetDeviceIDs'
saxpy.cpp:(.text+0x196): undefined reference to `clCreateContext'
saxpy.cpp:(.text+0x1b9): undefined reference to `clCreateCommandQueue'
saxpy.cpp:(.text+0x1df): undefined reference to `clCreateBuffer'
saxpy.cpp:(.text+0x205): undefined reference to `clCreateBuffer'
saxpy.cpp:(.text+0x22b): undefined reference to `clCreateBuffer'
saxpy.cpp:(.text+0x271): undefined reference to `clEnqueueWriteBuffer'
saxpy.cpp:(.text+0x2b6): undefined reference to `clEnqueueWriteBuffer'
saxpy.cpp:(.text+0x2db): undefined reference to `clCreateProgramWithSource'
saxpy.cpp:(.text+0x305): undefined reference to `clBuildProgram'
saxpy.cpp:(.text+0x31d): undefined reference to `clCreateKernel'
saxpy.cpp:(.text+0x341): undefined reference to `clSetKernelArg'
saxpy.cpp:(.text+0x361): undefined reference to `clSetKernelArg'
saxpy.cpp:(.text+0x381): undefined reference to `clSetKernelArg'
saxpy.cpp:(.text+0x3a1): undefined reference to `clSetKernelArg'
saxpy.cpp:(.text+0x3f5): undefined reference to `clEnqueueNDRangeKernel'
saxpy.cpp:(.text+0x43a): undefined reference to `clEnqueueReadBuffer'
saxpy.cpp:(.text+0x449): undefined reference to `clFlush'
saxpy.cpp:(.text+0x458): undefined reference to `clFinish'
saxpy.cpp:(.text+0x4f8): undefined reference to `clReleaseKernel'
saxpy.cpp:(.text+0x507): undefined reference to `clReleaseProgram'
saxpy.cpp:(.text+0x516): undefined reference to `clReleaseMemObject'
saxpy.cpp:(.text+0x525): undefined reference to `clReleaseMemObject'
saxpy.cpp:(.text+0x534): undefined reference to `clReleaseMemObject'
saxpy.cpp:(.text+0x543): undefined reference to `clReleaseCommandQueue'
saxpy.cpp:(.text+0x552): undefined reference to `clReleaseContext'
collect2: error: ld returned 1 exit status
Maverick
  • 963
  • 9
  • 29

0 Answers0