views:

908

answers:

2

I'm getting my feet wet with OpenCL. I'm sure this problem is not specific to OpenCL, however.

the top of my main file looks like:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <OpenCL/opencl.h>

// some code

cl_device_id device_id; //declaring a device id gives no errors

int err = clGetDeviceIDs(NULL, CL_DEVICE_TYPE_GPU, 1, &device_id, NULL);
//the above API call does give an error.

I'm doing this on Snow Leopard. I can build and run Apple's examples using XCode. I can also compile and run NVIDIA's sample code by running make.

How do I properly compile my code without using XCODE?

+3  A: 
$ gcc -framework OpenCL hello.c

and

$ gcc -framework opencl hello.c

both work. Anyone want to try this on a non-OSX environment?

Derrick
A: 

I built some simple examples using Eclipse CDT. I needed to also change #include <OpenCL/opencl.h> to #include <opencl.h> outside of XCode, and add -I /System/Library/Frameworks/OpenCL.framework/Headers (or something similar).

alexr