Building the SDK 4.1 /usr/bin/ld: cannot find -lcuda

Not getting anywhere w/ the linux people,…

I’ve got a new machine, and trying to build the code examples in the SDK. The build doesn’t get very far.
It err’s at the device query project.
The linker can’t find a library, and I’m not sure why.
The paths are setup as described in the install doc’s.

~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/local/cuda/bin

~/NVIDIA_GPU_Computing_SDK/C/bin/linux/release$ ldconfig -v | grep cuda
/sbin/ldconfig.real: Path /lib/x86_64-linux-gnu' given more than once /sbin/ldconfig.real: Path /usr/lib/x86_64-linux-gnu’ given more than once
/usr/local/cuda/lib64: ->
/usr/local/cuda/lib: -> -> -> ->

~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery$ gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2

~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 295.20 Mon Feb 6 21:07:30 PST 2012

~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery$ uname -m && cat /etc/*release

~/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery$ make
/usr/bin/ld: cannot find -lcuda
collect2: ld returned 1 exit status
make: *** […/…/bin/linux/release/deviceQuery] Error 1

From the projects makefile:
(The line causing the problem.)
LIB += -lcuda

I’m not sure where in the make environment that LIB is created.
I’m not sure where the files are located, but they are in the ldconfig. (see above)
I tried it with the LD_LIBRARY_PATH environment var as well and got the same err.

I can build and run the bandwidthTest project.

Any suggestion to fixing the build?

libcuda is installed by the driver.

What is the output of “locate” ?


Both the and are links to

I reinstalled the latest driver, just for the heck of it. Still the same err.
sudo apt-get install --reinstall nvidia-current

My starting point for all this was a fresh install of 11.04.
Everything was installed to the default locations.

Thanks for the response.

Hi, I met nearly the same problem and troubled me both when I want to compile the gpu SDK samples and pyCUDA. However I just solved it.

The brief profile of my computer and os is listed below:

OS  : Fedora 16
GPU: GeForce GTX550Ti
DRV: yum installed the akmod-nvidia driver, and banned the nouveau driver came from Fedora
CUDAToolkit : Latest Verson

When I came to the procedure of compiling SDK samples, it would exit with error : “/usr/bin/ld: cannot find -lcuda”, the same thing happend when
I just want to compile and install pyCUDA package. However I could find in path /usr/lib64/nvidia/.

I searched out a webpage " " and the last suggested that make symbolic links like:

ln -s /usr/lib64/nvidia/ /usr/lib64/ && ln -s /usr/lib64/nvidia/ /usr/lib64/

And this command solved my problem.

Thanks, that did it. (Looking for the library in a different location.)
The libraries are in the “nvidia-current” folder, but the linker is looking in the “lib” folder.

Make a symbolic link in the “lib” folder that points to the “nvidia-current” folder:
sudo ln -s /usr/lib/nvidia-current/ /usr/lib/ && ln -s /usr/lib/nvidia-current/ /usr/lib/libcuda/so.1

son of devil google. ‘/usr/bin/ld: cannot find lcuda’ search gave me link to all 3 threads i made for pycuda installtion error. But, didn’t brought me here. I have wandered a lot. This is a useful thread.

Arguably the safer option is adding


to you linker flags. In the case of the CUDA SDK change to

LINKFLAGS += -L/usr/lib/nvidia-current