Reputation: 696
I have done some CUDA programming at Windows and now I want to learn OpenCL. I have Macbook retina which contains Intel Iris
graphics card. I already have xCode
. I tried to find a lot at internet about how can I check if OpenCL is already installed at my Mac but I could not understand a proper way. I just read that Macbook will automatically get OpenCL installed with xCode.
I wrote few lines which are related to OpenCL but it throws error:
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)
I am completely new to OpenCL and unable to understand how things work with OpenCL.
My Code:
#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: Inclusion of header files does not throw any error. The error occurs due to clGetPlatformIDs()
in the main()
.
Upvotes: 1
Views: 1258
Reputation: 9925
You need to link against the OpenCL framework. This involves adding -framework OpenCL
to your command-line, or if you're using Xcode adding OpenCL.framework
to the Link Binary With Libraries section in Build Phases.
Upvotes: 4