fatal error 1083: Cannot open include file 'Cl/cl.h' no such

I am having difficulty getting code to compile in VS 2008. I have copied the .h files to the CL directory like it says to on http://www.khronos.org/registry/cl/ page but when I started to write a small segment of code to just make sure it will build i am getting the error: Cannot find CL\cl.h and if i change it to openCL.h for my include it tells me the same thing just cannot find CL\openCL.h

This is only a short piece of the code that should compile and build according to this website and also straight out of the book Heterogeneous Computing chapter 2 full source code.

#include <stdio.h>
#include <stdlib.h>
#include <CL\opencl.h>

const char* programSource =
"__kernel
"
"void vecadd(__global int *A,
"
" __global int *B,
"
" __global int *C,
"
"{
"
"
"
" // Get the work -item’s unique ID
"
" int idx = get_global_id(0);
"
"
"
" // Add the corresponding locations of
"
" // ‘A’ and ‘B’, and store result in ‘C’
"
" C[idx] = A[idx] + B[idx];
"
"}
"
;

int main()
{
int *A = NULL;
int *B = NULL;
int *C = NULL;

const int iElements = 2048;

size_t datasize = sizeof(int) * iElements;

A = (int*)malloc(datasize);
B = (int*)malloc(datasize);
C = (int*)malloc(datasize);


for ( int i = 0; i &lt; iElements; i++)
	{
		A[i] = i;
		B[i] = i;
	}


cl_int status;

//STEP 1
cl_uint numPlatforms = 0;
cl_platform_id *platforms = NULL;

status = clGetPlatformIDS(0, NULL, &numPlatforms);

platforms = (cl_platform_id*)malloc(numPlatforms * sizeof(cl_platform_id));

status = clGetPlatformIDs(numPlatforms, platforms, NULL);

//STEP 2
cl_uint numDevices = 0;
cl_device_id*devices = NULL;

status = clGetDeviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, 0, NULL, &numDevices);

devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));

status = clGetDEviceIDs(platforms[0], CL_DEVICE_TYPE_ALL, numDevices, devices, NULL);

// STEP 3

}

I have tried to “include” this directory within the VS IDE by going to Tools/options/ VC++ directories and manually adding C:\CL to it but it still fails to build because it cannot find the file. Also it really seems like something is missing from the website because while i see all of the .h files as includes and i have looked into everyone of them I see function prototypes and a ton of define statements but i don’t see any actual function code. Am I missing a library? Is it vendor specific? If so where do I get it? Yeah I’m a noob programmer but I tell you the thing I hate and that frustrates so many “noob” programmers is not having all of the files in the right places to build with. I am really interested in Learning openCL and i have a lot of experience in C but I swear Microsoft programmers should be shot for making VS so damned complicated to use. Yeah I’ve tried other IDE’s like Net beans but cant even get them to build the simple examples in Deitel and Deitel with out 500 errors. Thanks for any help and please forgive the rant but its something that really needs to be addressed in the programming community so that “noobs” can learn to program and not fight the IDE’s.

Hi,
It seems like you haven’t installed any openCL implementation. You need to download
one from some vendor depending on the hardware you wish to use. If you have an nvidia
graphics card then go to nvidia’s site and download the CUDA libraries (it includes OpenCL),
or if you have an ATI card go to AMD’s site and download and install their implementation. You
will need to make sure you have the right graphics driver to match the version of the library you
install. If want to use the CPU then you can download implementations from either AMD or Intel.


jason

Thanks Jason, but I have installed the AMD APP SDK and all of their sample programs build and run fine. They even have the same #include<CL\cl.h> in their files and ironically even when I have deleted that directory it still compiles and runs their code. They obviously have something else going on with their environment settings in VS that I can’t duplicate myself because I don’t know what or where it is. I even went to the extreme of starting my own project and literally just copy /pasted their code into it and it still gives me that very same error(even though I had restored the CL\ path and files). Yeah I hear you saying well just use their files and change everything around to what you want, but then that really limits me to only build one program and further more it doesn’t give me the flexibility I need to develop solutions. All I really need to know is

  1. What changes have they made to their environment variables in VS that it compiles and runs.
  2. What Library file I need to have in my project folder.
    I don’t need, nor do I want any of their sample code in my projects. I simply want to use the Headers given by Khronos and the machine dependent code given by AMD and I only need to know what the names of the files are and where they are located so I can move them to my projects. Thanks

Hi, this might be a little late (since the post originated in February) but worth sharing for anyone else who’s had the same problem…

I had the same error but managed to fix it by pointing the “Additional Include Directories” to the AMD APP (part of the SDK) installation directory;

In the Project Properties (View -> Properties), select “All Configurations” from the drop down menu, then under “Configuration Properties” -> C/C++ -> General, add the Additional Include Directories and navigate to the AMD APP include installation directory (on my PC it is located at “C:\Program Files (x86)\AMD APP\include”).

Should then pick up the CL/xxx.xx files that are contained within the folder.

Hope that’s of some help to someone (",)

Thanks ajgooch, I took a rather long route to fix this, the details of which elude me at the moment because its been 9 months since i worked on that project, I did eventually get everything to work though and even made my own .dll and lib files so that I never have the issues again.