rjuang / opencl-toolbox

Automatically exported from code.google.com/p/opencl-toolbox
MIT License
0 stars 1 forks source link

linking error while installing toolbox #11

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
From a Terminal:
1. cd /some/directory/opencl_include (for example)

2. ln -s /System/Library/Frameworks/OpenCL.framework/Headers/ CL

3. ln -s CL/ OpenCL

From Matlab:
4. cd(matlabroot)
edit bin/mexopts.sh
line 137:             CLIBS="$MLIBS -framework OpenCL"
line 150:            CXXLIBS="$MLIBS -lstdc++ -framework OpenCL"

% %%%%%%%%%%%%%%%% CONFIGURATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
opencl_include_dir = '/some/directory/opencl_include';
opencl_lib_dir = '/System/Library/Frameworks/OpenCL.framework/Libraries';
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mex('src/openclcmd.cpp', '-Iinclude', ['-I' opencl_include_dir] );

What is the expected output? What do you see instead?

Instead of building the program, I get a linking error:

Error using mex
Undefined symbols for architecture x86_64:
  "_clBuildProgram", referenced from:
      ray::opencl::OCLProgram::build(std::vector<_cl_device_id*, std::allocator<_cl_device_id*> >&,
      char const*) in openclcmd.o
  "_clCreateBuffer", referenced from:
      ray::opencl::OCLBuffer::create() in openclcmd.o
  "_clCreateCommandQueue", referenced from:
      ray::opencl::OCLCommandQueue::create() in openclcmd.o
  "_clCreateContext", referenced from:
      ray::opencl::OCLContext::create() in openclcmd.o
  "_clCreateKernel", referenced from:
      ray::opencl::OCLKernel::OCLKernel(ray::opencl::OCLProgram&, char const*) in openclcmd.o
  "_clCreateProgramWithBinary", referenced from:
      ray::opencl::OCLProgram::create_from_binary() in openclcmd.o
  "_clCreateProgramWithSource", referenced from:
      ray::opencl::OCLProgram::create_from_source() in openclcmd.o
  "_clEnqueueNDRangeKernel", referenced from:
      ray::opencl::OCLCommandQueue::enqueue_ndrange_kernel(ray::opencl::OCLKernel*,
      ray::opencl::OCLEvent*) in openclcmd.o
  "_clEnqueueReadBuffer", referenced from:
      get_buffer(mxArray_tag**, mxArray_tag const*, mxArray_tag const*, mxArray_tag const*,
      mxArray_tag const*) in openclcmd.o
      ray::opencl::OCLCommandQueue::enqueue_buffer_copy(void*, _cl_mem*, unsigned long, unsigned
      long, unsigned int, unsigned int, _cl_event* const*, ray::opencl::OCLEvent*) in openclcmd.o
  "_clEnqueueWriteBuffer", referenced from:
      set_buffer(mxArray_tag**, mxArray_tag const*, mxArray_tag const*, mxArray_tag const*) in
      openclcmd.o
      ray::opencl::OCLCommandQueue::enqueue_buffer_copy(_cl_mem*, void const*, unsigned long,
      unsigned long, unsigned int, unsigned int, _cl_event* const*, ray::opencl::OCLEvent*) in
      openclcmd.o
  "_clFinish", referenced from:
      set_buffer(mxArray_tag**, mxArray_tag const*, mxArray_tag const*, mxArray_tag const*) in
      openclcmd.o
      get_buffer(mxArray_tag**, mxArray_tag const*, mxArray_tag const*, mxArray_tag const*,
      mxArray_tag const*) in openclcmd.o
      wait_queue(mxArray_tag**, mxArray_tag const*) in openclcmd.o
  "_clGetCommandQueueInfo", referenced from:
      ray::opencl::OCLCommandQueue::query_info() in openclcmd.o
  "_clGetContextInfo", referenced from:
      ray::opencl::OCLContext::query_info() in openclcmd.o
  "_clGetDeviceIDs", referenced from:
      ray::opencl::OCLPlatform::get_device_ids(ray::opencl::ocl_device_type) in openclcmd.o
  "_clGetDeviceInfo", referenced from:
      ray::opencl::OCLDevice::OCLDevice(_cl_device_id*) in openclcmd.o
  "_clGetMemObjectInfo", referenced from:
      ray::opencl::OCLBuffer::query_info() in openclcmd.o
  "_clGetPlatformIDs", referenced from:
      ray::opencl::OCLPlatform::get_platform_ids() in openclcmd.o
  "_clGetPlatformInfo", referenced from:
      ray::opencl::OCLPlatform::OCLPlatform(_cl_platform_id*) in openclcmd.o
  "_clGetProgramBuildInfo", referenced from:
      ray::opencl::OCLProgram::query_build_info() in openclcmd.o
  "_clGetProgramInfo", referenced from:
      ray::opencl::OCLProgram::query_info() in openclcmd.o
  "_clReleaseCommandQueue", referenced from:
      ray::opencl::OCLCommandQueue::create() in openclcmd.o
      ray::opencl::OCLObject<_cl_command_queue*>::~OCLObject() in openclcmd.o
  "_clReleaseContext", referenced from:
      ray::opencl::OCLContext::create() in openclcmd.o
      ray::opencl::OCLObject<_cl_context*>::~OCLObject() in openclcmd.o
  "_clReleaseEvent", referenced from:
      ray::opencl::OCLCommandQueue::enqueue_ndrange_kernel(ray::opencl::OCLKernel*,
      ray::opencl::OCLEvent*) in openclcmd.o
      ray::opencl::OCLCommandQueue::enqueue_buffer_copy(void*, _cl_mem*, unsigned long, unsigned
      long, unsigned int, unsigned int, _cl_event* const*, ray::opencl::OCLEvent*) in openclcmd.o
      ray::opencl::OCLCommandQueue::enqueue_buffer_copy(_cl_mem*, void const*, unsigned long,
      unsigned long, unsigned int, unsigned int, _cl_event* const*, ray::opencl::OCLEvent*) in
      openclcmd.o
  "_clReleaseKernel", referenced from:
      ray::opencl::OCLObject<_cl_kernel*>::~OCLObject() in openclcmd.o
  "_clReleaseMemObject", referenced from:
      ray::opencl::OCLObject<_cl_mem*>::~OCLObject() in openclcmd.o
      ray::opencl::OCLBuffer::create() in openclcmd.o
  "_clReleaseProgram", referenced from:
      ray::opencl::OCLProgram::create() in openclcmd.o
      ray::opencl::OCLObject<_cl_program*>::~OCLObject() in openclcmd.o
  "_clRetainContext", referenced from:
      ray::opencl::OCLContext::OCLContext(_cl_context*) in openclcmd.o
  "_clSetKernelArg", referenced from:
      set_kernel_args(mxArray_tag**, mxArray_tag const*, mxArray_tag const*, mxArray_tag const*,
      mxArray_tag const*, mxArray_tag const*) in openclcmd.o
  "_clUnloadCompiler", referenced from:
      ray::opencl::OCLProgram::build(std::vector<_cl_device_id*, std::allocator<_cl_device_id*> >&,
      char const*) in openclcmd.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Error in make (line 5)
mex('src/openclcmd.cpp', '-Iinclude', ['-I' opencl_include_dir]);

What version of the product are you using? On what operating system?

I'm using opencl-toolbox version 0.17 with Matlab 2014a and MacOS 10.7.5.

Original issue reported on code.google.com by a.tretti...@gmail.com on 17 Jun 2014 at 1:52

GoogleCodeExporter commented 9 years ago
SOLVED: 
cd(matlabroot)
edit bin/maci64/mexopts/clang++_maci64.xml

line 30: CXX="$XCRUN_DIR/xcrun -sdk macosx$SDKVER clang++ -framework OpenCL"

It appears that the mexopts.sh doesn't have any actual influence on the mex 
command, because in it I could change "clang" to, say, "clangs" without getting 
an error. In this file, however, this change would result in a "not found" 
error, meaning that this is the file that actually matters.

Original comment by a.tretti...@gmail.com on 17 Jun 2014 at 2:04