为什么我的openCL构建在OS X上失败?

时间:2011-10-05 15:34:41

标签: c macos opencl

我使用OS X 10.7 Lion并安装了所有开发工具,但是当我在一个相对简单的程序上运行GCC时,只需要调用open clCreateProgramFromSource之类的openCL函数等直接C,我得到以下错误列表:

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

还有一些其他警告,但在计算阶段没有其他错误。这是(如果不清楚)链接器错误。它似乎能够在创建目标文件时看到头文件中的定义,因为它给了我关于不兼容指针类型的警告。

我已经尝试粘贴到xcode项目中,但我得到了完全相同的错误。我试过only other OS X Lion / OpenCL result's solution,但没有帮助。

2 个答案:

答案 0 :(得分:13)

看起来你错过了OpenCL框架 - 试试:

$ gcc -Wall foo.c -framework OpenCL -o foo

答案 1 :(得分:2)

在我看来,你并没有链接到OpenCL库。你可以发布你想要使用的链接命令吗?没有这些信息,只需从臀部拍摄:添加-framework OpenCL