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:
libcudart.so.4 -> libcudart.so.4.1.28
/usr/local/cuda/lib:
libcudart.so.4 -> libcudart.so.4.1.28
libcuda.so.1 -> libcuda.so.295.20
libcuda.so.1 -> libcuda.so.295.20

libicudata.so.44 -> libicudata.so.44.2

~/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
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.04

~/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 libcuda.so 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?
Thanks

libcuda is installed by the driver.

What is the output of “locate libcuda.so” ?

locate libcuda.so
/usr/lib/nvidia-current/libcuda.so
/usr/lib/nvidia-current/libcuda.so.1
/usr/lib/nvidia-current/libcuda.so.295.20
/usr/lib32/nvidia-current/libcuda.so
/usr/lib32/nvidia-current/libcuda.so.1
/usr/lib32/nvidia-current/libcuda.so.295.20

Both the libcuda.so and libcuda.so.1 are links to libcuda.so.295.20.

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 libcuda.so libcuda.so.1 in path /usr/lib64/nvidia/.

I searched out a webpage "http://reset.etsii.upm.es/en/users/peque/installing-cuda-in-fedora-16/ " and the last suggested that make symbolic links like:

ln -s /usr/lib64/nvidia/libcuda.so /usr/lib64/libcuda.so && ln -s /usr/lib64/nvidia/libcuda.so.1 /usr/lib64/libcuda.so.1

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/libcuda.so /usr/lib/libcuda.so && ln -s /usr/lib/nvidia-current/libcuda.so.1 /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

-L/usr/lib/nvidia-current

to you linker flags. In the case of the CUDA SDK change common.mk:148 to

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