ubuntu -lcuda not found

Whilst making the SDK samples make fails on ld and it reports that it can’t find -lcuda, even though /usr/lib32/libcuda.so.1 and /usr/lib64/libcuda.so.1 exist

make[1]: Leaving directory `/home/david/NVIDIA_GPU_Computing_SDK/C/src/scanLargeArray'

make -C src/ptxjit/ 

make[1]: Entering directory `/home/david/NVIDIA_GPU_Computing_SDK/C/src/ptxjit'

/usr/bin/ld: cannot find -lcuda

collect2: ld returned 1 exit status

make[1]: *** [../../bin/linux/release/ptxjit] Error 1

make[1]: Leaving directory `/home/david/NVIDIA_GPU_Computing_SDK/C/src/ptxjit'

make: *** [src/ptxjit/Makefile.ph_build] Error 2

Does anyone have any suggestions to what i might do to fix the issue

I am using ubuntu 9.04 on an x86_64 platform.

setenv LD_LIBRARY_PATH /usr/local/cuda/lib64

(or whereever your toolkit libraries are.)

Perhaps you also don’t want to erase the other library paths :) I have this in my .bashrc instead
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64/

Just my 2 cents,
Cédric

Setting LD_LIBRARY_PATH will have no effect on your problem. My guess is that you have installed the CUDA toolkit in a non-standard location. For the SDK makefile, you need to either set CUDA_INSTALL_PATH to the root path of the toolkit installation, or edit this line in common.mk:

CUDA_INSTALL_PATH ?= /usr/local/cuda

to wherever you have the toolkit installed.

I think the cleanest solution to your problem is to modify the /etc/ld.co.conf. Here’s mine:

/usr/local/lib

/usr/local/lib64

/usr/x86_64-slamd64-linux/lib

/usr/lib

/usr/lib64

/lib

/lib64

/usr/lib/qt/lib

/usr/lib64/qt/lib

/usr/X11R6/lib

/usr/X11/

/home/moroe/mhgui-0.2/src/.libs

/usr/local/cuda/lib64

/usr/local/cuda/lib

/usr/lib64/qt-3.3.8/lib

In my case the relevant lines are 13 and 14. It might be another path on your system (e.g. /usr/lib/cuda/lib or something like that)

I think this solution will also help precompiled CUDA-Applications to find the libs.

–Teewurst

The problem the original poster is having is a linking problem. Nothing you can do to link loader settings will help.

Leaving that aside, I think modifying the link loader cache to include things like paths to CUDA is a very bad idea. Explicitly setting LD_LIBRARY_PATH allows fine grain control over versions (for example I have both CUDA 2.3 and CUDA 3.0 beta installed, and editing the link loader cache eliminates any control over which version of the library is found). Tools like Ocelot and barra rely on using reimplemented versions of the CUDA runtime libraries which intercept API calls and pass them to emulation code. They can never work if you hard code CUDA paths into the link library cache.

The best way to handle this stuff is using the excellent modules package. Using modules I can do this:

avid@cuda:~$ module avail

------------------------------------------- /opt/env/Modules/versions -------------------------------------------

3.2.7

-------------------------------------- /opt/env/Modules/3.2.7/modulefiles ---------------------------------------

acml/4.3.0		cuda/3.0b		 goto2/1.09		modules		   use.own

acml/4.3.0mp	  dot			   module-cvs		mpich2/r1.1.1p1

cuda/2.3(default) goto/1.19		 module-info	   null

avid@cuda:~$ module load cuda/2.3

avid@cuda:~$ nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2009 NVIDIA Corporation

Built on Thu_Jul_30_09:24:36_PDT_2009

Cuda compilation tools, release 2.3, V0.2.1221

avid@cuda:~$ module unload cuda

avid@cuda:~$ module load cuda/3.0b 

avid@cuda:~$ nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver

Copyright (c) 2005-2009 NVIDIA Corporation

Built on Mon_Oct_26_09:40:14_PDT_2009

Cuda compilation tools, release 3.0, V0.2.1221

avid@cuda:~$ module list

Currently Loaded Modulefiles:

  1) cuda/3.0b

that is, I can dynamically select whichever CUDA version I want, and all of the paths/libraries/compiler flags are automagically set for me and everything works seamlessly.

Just my 5 Euro cents.

I had the same problem after installing cuda5.5 in Ubuntu 12.04. The system is searching for the device drivers that run the display, but they have not been installed in the expected place. The libcuda.so and libcuda.so.1 files were installed in the following directories:
/usr/lib32/nvidia-current-updates/
/usr/lib/nvidia-current-updates/

I adapted a post I saw elsewhere here and created a symbolic link:
cd /usr/lib
sudo ln -s /usr/lib/nvidia-current-updates/libcuda.so libcuda.so

I should add, if you are not sure where on your system the libcuda.so driver files are located, there is an easy way to search:
cd /
find . -name libcuda* > ~/results
cat results

The files compile now, but I don’t know if everything works yet.