cannot find -lcuda

I try compile deviceQuery,

but when i do his return the error:

make -C src/deviceQuery/
make[2]: Entering directory /home/tiago/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery' /usr/bin/ld: cannot find -lcuda collect2: ld returned 1 exit status make[2]: *** [../../bin/linux/release/deviceQuery] Error 1 make[2]: Leaving directory /home/tiago/NVIDIA_GPU_Computing_SDK/C/src/deviceQuery’
make[1]: *** [src/deviceQuery/Makefile.ph_build] Error 2
make[1]: Leaving directory `/home/tiago/NVIDIA_GPU_Computing_SDK/C’
make: *** [all] Error 2

Any can help me, I am using Fedora 15 with gcc 4.4.6

1 Like

Try linking with -lcudart instead of -lcuda.

(I use Ubuntu 10, not Fedora.) Have you added the library installation folder (normally /usr/local/cuda/lib) to LD_LIBRARY_PATH? You also have to run ldconf after that to set up sonames.

But if you do an ls -l on that directory, you’ll see that there are no libcuda.so* files, so no matter what you do, -lcuda won’t be found. (True for CUDA 4.0 on my system, anyway.)

Then it might be in /usr/local/cuda/lib64. It should be somewhere. I successfully link to it myself. Check the library installation paths in /usr/local/cuda/bin/nvcc.profile, maybe it’s in one of those.

No, there’s only libcudart.so.* (4.0.17 in my installation). Likewise in nvcc.profile, it’s -lcudart, not -lcuda.

On my laptop it seems that lcuda.so is created under /usr/lib/. Do you have anything there?

libcuda.so is installed by the driver ( in /usr/lib or /usr/lib64 depending on your OS), libcudart.so is in the toolkit.
If you are using the driver API, you need to link to libcuda, if you are using the runtime API you need to link to libcudart.

Thanks for clearing this up. It makes a sort of sense, especially since I do a lot of work on my laptop, which does not have a CUDA device installed. The desktop machine which has the GPUs does have a libcuda in /usr/lib64, but my executables are always linked with -lcudart, since that works on either system. (And in fact my CUDA development directories on the desktop machine are just the notebook ones mounted via NFS.)

If you cared to expand on the differences between driver & runtime API (or point to some existing docs), I’d be interested.

Thanks for clearing this up. It makes a sort of sense, especially since I do a lot of work on my laptop, which does not have a CUDA device installed. The desktop machine which has the GPUs does have a libcuda in /usr/lib64, but my executables are always linked with -lcudart, since that works on either system. (And in fact my CUDA development directories on the desktop machine are just the notebook ones mounted via NFS.)

If you cared to expand on the differences between driver & runtime API (or point to some existing docs), I’d be interested.

I am using fedora 14. There was no libcuda.so at /usr/local/cuda/lib/. So I copied from /usr/lib/nvidia/ and make them. It works fine. Thanks a lot.

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