Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why are my openCL builds failing on OS X?

Tags:

c

macos

opencl

I'm on OS X 10.7 Lion and have all the dev tools installed, but when I run GCC on a relatively simple program, just straight C with a few calls to openCL functions like clCreateProgramFromSource and the like, I get the following list of errors:

Undefined symbols for architecture x86_64:
  "_CreateContext", referenced from:
    _build_kernel in ccFuZYMI.o
  "_GetDevices", referenced from:
    _build_kernel in ccFuZYMI.o
  "_CreateCommandQueue", referenced from:
    _build_kernel in ccFuZYMI.o
  "_clCreateProgramWithSource", referenced from:
    _build_kernel in ccFuZYMI.o
  "_clBuildProgram", referenced from:
    _build_kernel in ccFuZYMI.o
  "_clCreateKernel", referenced from:
    _build_kernel in ccFuZYMI.o
  "_clCreateBuffer", referenced from:
    _build_kernel in ccFuZYMI.o
  "_clEnqueueWriteBuffer", referenced from:
    _sync_run_kernel in ccFuZYMI.o
  "_clSetKernelArg", referenced from:
    _sync_run_kernel in ccFuZYMI.o
  "_clEnqueueNDRangeKernel", referenced from:
    _sync_run_kernel in ccFuZYMI.o
  "_clEnqueueReadBuffer", referenced from:
    _sync_run_kernel in ccFuZYMI.o
  "_clReleaseContext", referenced from:
    _destroy_kernel in ccFuZYMI.o
  "_clReleaseCommandQueue", referenced from:
    _destroy_kernel in ccFuZYMI.o
  "_clReleaseMemObject", referenced from:
    _destroy_kernel in ccFuZYMI.o
  "_clReleaseProgram", referenced from:
    _destroy_kernel in ccFuZYMI.o
  "_clReleaseKernel", referenced from:
    _destroy_kernel in ccFuZYMI.o
ld: symbol(s) not found for architecture x86_64

There are some other warnings, but no other errors at compulation stage. This is (in case not clear) a linker error. It seems to be able to see the definitions from the header file while creating the object file, because it gives me warnings about incompatible pointer types.

I have tried pasting into an xcode project, but I get exactly the same errors. I have tried the only other OS X Lion / OpenCL result's solution, and it didn't help.

like image 704
tehwalrus Avatar asked Oct 05 '11 15:10

tehwalrus


2 Answers

Looks like you're missing the OpenCL framework - try:

$ gcc -Wall foo.c -framework OpenCL -o foo
like image 126
Paul R Avatar answered Oct 20 '22 12:10

Paul R


It looks to me like you're not linking against the OpenCL libraries. Can you post the link command that you are trying to use? Without that information, simply shooting from the hip: add -framework OpenCL.

like image 26
Stephen Canon Avatar answered Oct 20 '22 12:10

Stephen Canon