Compiling an OpenCL program using a CL/cl.h file

sandra picture sandra · Jan 23, 2014 · Viewed 41.2k times · Source

I have sample "Hello, World!" code from the net and I want to run it on the GPU on my university's server. When I type "gcc main.c," it responds with:

CL/cl.h: No such file or directory

What should I do? How can I have this header file?

Answer

Michael Aquilina picture Michael Aquilina · Jan 27, 2014

Make sure you have the appropriate toolkit installed.

This depends on what you intend running your code on. If you have an NVidia card then you need to download and install the CUDA-toolkit which also contains the necessary binaries and libraries for opencl.

Are you running Linux? If you believe you already have OpenCL installed it could be that it is found at a different location than the standard /usr/include. Type the following and see what results you get:

find / -iname cl.h 2>/dev/null

On my laptop for example, the header is found at /usr/local/cuda-5.5/include. If its the case were your header file is at a different location you simply have to specify the path during complication

g++ -I/usr/local/cuda-5.5/include main.c -lOpenCL

Alternatively, you can create a symbolic link from the path to /usr/include:

ln -s /usr/local/cuda-5.5/include/CL /usr/include