Ubuntu – “cannot find -lOpenCL” error when making the Cuda SDK

librariesnvidiaopencl

I have an ASUS Notebook with nVidia gt 520m and thought about trying some OpenCL programming (first time) on Ubuntu 11.10. I installed the nvidia-current-dev package. Thus, I found libOpenCL.so and such in /usr/lib/nvidia-current/ folder:

$razvan@...:~$ locate libOpenCL.so
/usr/lib/nvidia-current/libOpenCL.so
/usr/lib/nvidia-current/libOpenCL.so.1
/usr/lib/nvidia-current/libOpenCL.so.1.0
/usr/lib/nvidia-current/libOpenCL.so.1.0.0
/usr/lib32/nvidia-current/libOpenCL.so
/usr/lib32/nvidia-current/libOpenCL.so.1
/usr/lib32/nvidia-current/libOpenCL.so.1.0
/usr/lib32/nvidia-current/libOpenCL.so.1.0.0

I then installed the CUDA Toolkit for Ubuntu 10.10 from nVidia website and also the NVIDIA GPU SDK (in /opt/gpu_sdk).

When I go to /opt/gpu_sdk/OpenCL and try the make command I get:

razvan@...:/opt/gpu_sdk/OpenCL$ make
make[1]: Entering directory `/opt/gpu_sdk/OpenCL/common'
a - obj/release/oclUtils.cpp.o
make[1]: Leaving directory `/opt/gpu_sdk/OpenCL/common'
make[1]: Entering directory `/opt/gpu_sdk/shared'
make[1]: Leaving directory `/opt/gpu_sdk/shared'
make -C src/oclConvolutionSeparable/
make[1]: Entering directory `/opt/gpu_sdk/OpenCL/src/oclConvolutionSeparable'
/usr/bin/ld: cannot find -lOpenCL
collect2: ld returned 1 exit status
make[1]: *** [../../..//OpenCL//bin//linux/release/oclConvolutionSeparable] Error 1
make[1]: Leaving directory `/opt/gpu_sdk/OpenCL/src/oclConvolutionSeparable'
make: *** [src/oclConvolutionSeparable/Makefile.ph_build] Error 2

Afeter installing the nvidia-current-dev package I went to /etc/ld.so.conf.d/ and made nvidia-current.conf where I specified /usr/lib/nvidia-current and /usr/lib32/nvidia-current. Then I used ldconfig for caching the new locations.

Needless to say, it didn't work. I also appended the /usr/lib/nvidia-current and /usr/lib32/nvidia-current to the LD_LIBRARY_PATH environment variable in the hope of working… it did not work.

Best Answer

Cannot set LD_LIBRARY_PATH which is related to /usr/bin/ld specifically.

Should have set LIBRARY_PATH which is the correct environment variable for the gnu compiler (used here).

Whatever the connection between LD_LIBRARY_PATH and LIBRARY_PATH (or in this case ld and gcc and why gcc doesn't use the ld executable..

Related Question