cannot find -lcuda


I just bought a GTX 460 and installed Ubuntu 10.10

When I try to compile the SDK sample programs appears the following error:

/usr/bin/ld: cannot find -lcuda

collect2: ld returned 1 exit status

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

make[1]: exit directory <</home/federico/NVIDIA_GPU_Computing_SDK/C/src/vectorAddDrv>>

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

I have already installed cuda-toolkit and cuda-sdk.

The current cuda-driver is: 260.19.06

I didn’t install the newest driver because when I installed it and then reboot there’s no more GUI and if I try to launch the X-Server appears this:

Error: API mismatch: the NVIDIA kernel module has the version 260.19.26, but this X module has the version 260.19.06. Please make sure that the kernel module and all NVIDIA driver components have the same version.

And don’t know how to solve that problem, that’s why I didn’t install the latest driver.

So resuming…

Why I get the error “cannot find -lcuda”? if that problem is attached to the driver version, How can I solve the problem of the X server. I’m really new to linux.


libcuda should be in /usr/lib or /usr/lib64 … This comes with the driver installation!

Yeah thanks finally I could manage it :D

In current releases of the nvidia driver libcuda is located in


, which is the cause of this error. Add


to your compiler flags.

Sorry to be a pain but could you tell me where exactly I need to add this to compiler flags? Don’t know where they are?



Hey there,

For compiling your own code, you can just add the library to link to as an argument to nvcc:
nvcc -L/usr/lib/nvidia-current/cuda -o myprog -lcuda

(See: )

However, in this case, your trying to compile the SDK examples which have their own Makefiles. This care somewhat complicated as one Makefile sources some other common ones, etc. I believe what you need to do is add the library path to your /etc/ and run ldconfig. (The install instructions for Linux used to say to add /usr/lib/cuda or /usr/lib64/cuda to - if the new version has changed the default lib path, you will need to use it instead.)

Also, the getting started guide and release notes at: are helpful.


Hello everyone I just wanted to share my solution to compiling all the samples in cuda folder I am using the latest nvidia driver on fedora 331 with bumblebee for optimus configuration the lcuda library is located in /usr/lib64/nvidia-bumblebee but I suspect the same solution may be valid for nvidia without bumblebee configuration.

Anyway I tried appending to and running ldconfig but no change was detected but after adding the nvidia-bumblebee library to EXTRA_NVCCFLAGS in the makefile of a sample that previously produced the error the sample compiled so the solution was to edit all the makefiles in order to append -L/usr/lib64/nvidia-bumblebee to EXTRA_NVCCFLAGS.

I used find-name-dired function in emacs

and then added this regex when asked (^EXTRA_NVCCFLAGS ?=) to replace with (EXTRA_NVCCFLAGS ?= -L/usr/lib64/nvidia-bumblebee) after that everything compiled normally.