View Full Version : How to add header?

04-19-2010, 10:06 AM
I have a Struct named AES_KEY defined in OpenCL_AES_wrapper.h i use:
cl_program program=clCreateProgramWithSource(context,1,&source,NULL,NULL);
source is:
source="__kernel void encrypt_constant(__global const AES_KEY *key,__global const unsigned int *ivec,unsigned int loop_count,__global unsigned int *device_output)\n"
how to include my header file for recognized the struct type?
thanks in advance.

04-19-2010, 01:06 PM
There a basically two ways.

char* sources[2];
sources[0] = readFile("OpenCL_AES_wrapper.h"); // Use whatever you use now to read files
sources[1] = source;
...WithSource(context, 2, sources, ...

and the second is to use build options. See specification 5.4.2 and 5.4.3. In particular (-I) dir.

04-19-2010, 02:05 PM
the second way is for example:
const char*opt="-I .\my header directory"
sources[0] = "OpenCL_AES_wrapper.h";
sources[1] = source;
with clCreateProgram(context,2,sources
and clBuildProgram (...,opt
or i have to use only
const char*opt="-I .\my header directory"
with clBuildProgram (...,

04-19-2010, 03:50 PM
You can use #include directive in opencl sources.

04-20-2010, 06:53 AM
thanks i have resolve it with:
const char *options="-I ./lib";//if i don't use it make error
cl_program program=clCreateProgramWithSource(context,1,&source,NULL,NULL);

source="#include <aes.h>\n"
"__kernel void encrypt(__global const AES_KEY *key,__global const unsigned int *ivec,unsigned int loop_count,__global unsigned int *device_output)\n"...
this way work correctly
thanks for hint