我刚刚在我的64位ubuntu盒子上对clang 3.4进行了全新安装,我正在尝试编译一个使用OpenCV的项目。 Clang和OpenCV库都是使用apt-get从ubuntu存储库安装的。使用GCC构建工作正常。构建过程由CMake管理。
当我使用Clang运行构建时,我收到以下错误:
/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'
他们似乎与OpenCL有关。如何修复这些链接器错误?
答案 0 :(得分:2)
尝试手动编译。有时通过数据包管理器安装依赖项存在一些问题。而CMake是一个非常强大的工具。它执行编译器,平台等检查。
安装cmake(通过数据包管理器)并从存储库下载最后一个OpenCV源:
https://github.com/Itseez/opencv
并在shell上键入蛋糕构建的标准命令:
$ cd opencv_path
$ mkdir build
$ cmake ..
$ make
执行cake还可以输出一些重要信息,最好阅读它们:)
opencv的CMake脚本还为您提供了一种配置CUDA和OpenCL的好方法!