Max Ehrlich
Max Ehrlich

Reputation: 2525

Compiling OpenCV based project using Clang

I have just done a fresh install on clang 3.4 on my 64 bit ubuntu box, and I am trying to compile a project that uses OpenCV. Both Clang and the OpenCV libraries were installed from the ubuntu repository using apt-get. The build works fine using GCC. The build process is managed by CMake.

When I run the build using Clang I get the following errors:

/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clReleaseMemObject@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetKernelWorkGroupInfo@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clFlush@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined  reference to `clReleaseKernel@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clReleaseCommandQueue@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clReleaseEvent@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueWriteBuffer@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueCopyBufferRect@OPENCL_1.1'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateBuffer@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clFinish@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clBuildProgram@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueFillBuffer@OPENCL_1.2'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clSetKernelArg@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateProgramWithBinary@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateContext@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clReleaseProgram@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetDeviceIDs@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetEventProfilingInfo@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueUnmapMemObject@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clRetainCommandQueue@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateProgramWithSource@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateKernel@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetDeviceInfo@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clReleaseContext@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clRetainContext@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateCommandQueue@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueNDRangeKernel@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clWaitForEvents@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueReadBuffer@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueMapBuffer@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clCreateImage@OPENCL_1.2'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueWriteBufferRect@OPENCL_1.1'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueCopyBufferToImage@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetProgramBuildInfo@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetPlatformIDs@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clGetProgramInfo@OPENCL_1.0'
/usr/lib64/gcc/x86_64-linux-gnu/4.8/../../../../lib64/libopencv_ocl.so: undefined reference to `clEnqueueReadBufferRect@OPENCL_1.1'

They seem to be OpenCL related. How can I fix these linker errors?

Upvotes: 1

Views: 6428

Answers (1)

nkint
nkint

Reputation: 11733

Try to compile it manually. Sometimes there are some problems in installing dependencies via packet manager. And CMake is a very powerful tool. It performs check on compilers, platforms, etc.

Install cmake (via packet manager) and download the last OpenCV source from the repository:

https://github.com/Itseez/opencv‎

and type on the shell the standard command for cake building:

$ cd opencv_path
$ mkdir build
$ cd build
$ cmake ..
$ make

executing cake can also output some important information, it is better to read them : )

CMake script for opencv also gives you a nice way to configure CUDA and OpenCL!

Upvotes: 2

Related Questions