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

浪子不回头ぞ 提交于 2019-12-18 12:52:54

问题


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?


回答1:


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



回答2:


Are you using Ubuntu or Debian distro? Then you could use this package to solve the problem with missing header file:

apt-get install opencl-headers

You must install opencl library to solve linking issues using that Debian and Ubuntu package:

apt-get install ocl-icd-libopencl1

You can also use these nonfree libraries: nvidia-libopencl1 (Debian) or nvidia-libopencl1-xx (Ubuntu).



来源:https://stackoverflow.com/questions/21301905/compiling-an-opencl-program-using-a-cl-cl-h-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!