我在Windows做过一些CUDA编程,现在我想学习OpenCL。我有Macbook视网膜,其中包含Intel Iris显卡。我已经有xCode了。我试图在互联网上找到很多关于如何检查OpenCL是否已经安装在我的Mac上的问题,但我无法理解正确的方式。我刚读到Macbook会自动将OpenCL与xCode一起安装。
我写了一些与OpenCL相关的行,但是它会抛出错误:
Undefined symbols for architecture x86_64:
"_clGetPlatformIDs", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)我对OpenCL完全陌生,无法理解OpenCL是如何工作的。
我的代码:
#ifdef __APPLE__
#include "OpenCL/opencl.h"
#else
#include "CL/cl.h"
#endif
#include <iostream>
using namespace std;
int main()
{
cl_uint platformIdCount = 0;
clGetPlatformIDs (0, nullptr, &platformIdCount);
cout<<"Test openCL";
return 0;
}PS:包含头文件不会引发任何错误。此错误是由于clGetPlatformIDs()在main()中发生的。
发布于 2015-09-09 19:26:27
您需要链接到OpenCL框架。这包括将-framework OpenCL添加到命令行,或者如果使用Xcode,则将OpenCL.framework添加到构建阶段中的链接二进制库部分。
https://stackoverflow.com/questions/32486825
复制相似问题