add header file using clCreateProgramWithSource


I added a header file to my program using clCreateProgramWithSource,

because I had errors that the code doesn’t recognize variables defined in the .h file

this is my code:

[codebox]const char* files[2];

size_t include_length;

const char* include_path = “C:/Users/localcontrol/Desktop/work/nvidia3.0/cv.h”;

char *cvinclude = oclLoadProgSource(include_path, “”, &include_length);

printf( “cv path %s\n”, include_path);

//printf( “%s\n”, cvinclude);

printf( “include_length %d\n”, include_length);

shrCheckErrorEX(cvinclude != NULL, shrTRUE, pCleanup);

size_t program_length;

const char* source_path = shrFindFilePath(clSourcefile, argv[0]);

char *source = oclLoadProgSource(source_path, “”, &program_length);

printf( “cl path %s\n”, source_path);

//printf( “%s\n”, source);

printf( “program_length %d\n”, program_length);

shrCheckErrorEX(source != NULL, shrTRUE, pCleanup);

files[0] = cvinclude;

files[1] = source;

size_t lenghts[2];

lenghts[0] = include_length;

lenghts[1] = program_length;

printf( “%s\n”, files[0]);

printf( “%s\n”, files[1]);

// create the program

cpProgram = clCreateProgramWithSource(cxGPUContext, 2, (const char **) &files, (const size_t *) lenghts, &ciErrNum);

oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);

// build the program

ciErrNum = clBuildProgram(cpProgram, 0, NULL, “-cl-mad-enable”, NULL, NULL);[/codebox]

but it doesn,t build my program,

I get Error # 1 at file .c

I attache the build log I’m gettin, before and after adding .h file.

Help please.


I am facing the same problem.Did you able to fix this.

I want to include third party header files so that I can perform some computational tasks in my kernel.
Can I able to do that?