PDA

View Full Version : add header file using clCreateProgramWithSource



opencl_JEDI
03-10-2010, 05:57 AM
Hi,

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:

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);
but it doesn,t build my program,
I get Error # 1 at file .c

can anyone see if I made mistakes in my code
Help please.

dbs2
03-10-2010, 10:34 AM
There have been several people reporting problems with Nvidia drivers and loading header files. Try pasting your header file code directly into the file you send to clCreateProgram and see if it works.