error compiling SDK - "/usr/bin/ld: cannot find -lcuda"

Hello,

I try to compile the cuda SDK examples etc. but I’m getting this error:

/usr/bin/ld: cannot find -lcuda

collect2: ld returned 1 exit status

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

make[1]: Leaving directory `/home/jafar/NVIDIA_GPU_Computing_SDK/C/src/deviceQueryDrv'

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

I run ubuntu 10.04 64bits and I did downgrade to gcc 4.3 already. My nvidia driver version is 195.36.15

Any idea? Thanks in advance

I’m not sure. Do you have LD_LIBRARY_PATH set to /usr/local/cuda/lib or /lib?

Do you have the toolkit installed as well?

I’m not sure. Do you have LD_LIBRARY_PATH set to /usr/local/cuda/lib or /lib?

Do you have the toolkit installed as well?

I have the same problem! There is no libcuda* in the CUDA installation directory! There are only the following files:

libcublas.so@ libcudart.so@ libcufft.so@

libcublas.so.3@ libcudart.so.3@ libcufft.so.3@

libcublas.so.3.0.14* libcudart.so.3.0.14* libcufft.so.3.0.14*

libcublasemu.so@ libcudartemu.so@ libcufftemu.so@

libcublasemu.so.3@ libcudartemu.so.3@ libcufftemu.so.3@

libcublasemu.so.3.0.14* libcudartemu.so.3.0.14* libcufftemu.so.3.0.14*

But in the common.mk of the Cuda SDK package there is a line linking lcuda:

ifdef cuda-install

    CUDA_INSTALL_PATH := $(cuda-install)

 LIB += -lcuda   ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} 

     LIB += -lcudartemu

     LIB += -lcudart

BTW: I get the error only if I try to compile all SDK examples at once from the SDK/C directory. I can compile them separately from the individual directories. I guess that cuda-install is not defined then. So what is -lcuda good for then???

What can I do? I installed Cuda Toolkit 3.0 and the Cuda SDK. And also the latest driver.

Please help!

There shouldn’t be. libcuda is part of the driver package, not the toolkit. If you are getting libcuda not found errors it means you don’t have a suitable driver package installed.

Are you by any chance using the automatically downloaded “proprietary” driver on Ubuntu? That driver gave me the same issues; downloaded and installed the driver from nVidia, and it worked.

Are you by any chance using the automatically downloaded “proprietary” driver on Ubuntu? That driver gave me the same issues; downloaded and installed the driver from nVidia, and it worked.[/-]

Oops :)

I’m having the same issue with a fress Ubuntu 10.04 64bit install. However I find it very strange…

In /usr/lib/nvidia-current/ I have the following:

liad@monster:~$ ls -l /usr/lib/nvidia-current/

total 53396

drwxr-xr-x 2 root root	 4096 2010-06-04 18:31 bin

-rw-r--r-- 1 root root	   80 2010-06-04 23:52 ld.so.conf

lrwxrwxrwx 1 root root	   20 2010-06-04 18:31 libcuda.so -> libcuda.so.195.36.24

lrwxrwxrwx 1 root root	   20 2010-06-04 18:31 libcuda.so.1 -> libcuda.so.195.36.24

-rw-r--r-- 1 root root  7404496 2010-05-27 12:25 libcuda.so.195.36.24

lrwxrwxrwx 1 root root	   22 2010-06-04 18:31 libGLcore.so.1 -> libGLcore.so.195.36.24

-rw-r--r-- 1 root root 28838832 2010-05-27 12:25 libGLcore.so.195.36.24

lrwxrwxrwx 1 root root	   10 2010-06-04 18:31 libGL.so -> libGL.so.1

lrwxrwxrwx 1 root root	   18 2010-06-04 18:31 libGL.so.1 -> libGL.so.195.36.24

-rw-r--r-- 1 root root   956472 2010-05-27 12:25 libGL.so.195.36.24

lrwxrwxrwx 1 root root	   18 2010-06-04 18:31 libnvidia-cfg.so -> libnvidia-cfg.so.1

lrwxrwxrwx 1 root root	   26 2010-06-04 18:31 libnvidia-cfg.so.1 -> libnvidia-cfg.so.195.36.24

-rw-r--r-- 1 root root   136088 2010-05-27 12:25 libnvidia-cfg.so.195.36.24

lrwxrwxrwx 1 root root	   23 2010-06-04 18:31 libnvidia-compiler.so -> libnvidia-compiler.so.1

lrwxrwxrwx 1 root root	   31 2010-06-04 18:31 libnvidia-compiler.so.1 -> libnvidia-compiler.so.195.36.24

-rw-r--r-- 1 root root 17121832 2010-05-27 12:25 libnvidia-compiler.so.195.36.24

lrwxrwxrwx 1 root root	   26 2010-06-04 18:31 libnvidia-tls.so.1 -> libnvidia-tls.so.195.36.24

-rw-r--r-- 1 root root	 6248 2010-05-27 12:25 libnvidia-tls.so.195.36.24

lrwxrwxrwx 1 root root	   14 2010-06-04 18:31 libOpenCL.so -> libOpenCL.so.1

lrwxrwxrwx 1 root root	   16 2010-06-04 18:31 libOpenCL.so.1 -> libOpenCL.so.1.0

lrwxrwxrwx 1 root root	   18 2010-06-04 18:31 libOpenCL.so.1.0 -> libOpenCL.so.1.0.0

-rw-r--r-- 1 root root	20896 2010-05-27 12:25 libOpenCL.so.1.0.0

lrwxrwxrwx 1 root root	   26 2010-06-04 18:31 libXvMCNVIDIA_dynamic.so.1 -> libXvMCNVIDIA.so.195.36.24

lrwxrwxrwx 1 root root	   26 2010-06-04 18:31 libXvMCNVIDIA.so -> libXvMCNVIDIA.so.195.36.24

lrwxrwxrwx 1 root root	   26 2010-06-04 18:31 libXvMCNVIDIA.so.1 -> libXvMCNVIDIA.so.195.36.24

-rw-r--r-- 1 root root   147368 2010-05-27 12:25 libXvMCNVIDIA.so.195.36.24

-rw-r--r-- 1 root root	   28 2010-05-27 12:24 modprobe.conf

drwxr-xr-x 2 root root	 4096 2010-06-04 18:34 tls

drwxr-xr-x 2 root root	 4096 2010-06-04 18:31 vdpau

drwxr-xr-x 2 root root	 4096 2010-06-04 18:31 xorg

-rw-r--r-- 1 root root	   27 2010-05-27 12:24 XvMCConfig

and my /etc/ld.so.conf file looks like so:

liad@monster:~$ cat /etc/ld.so.conf

/usr/lib/nvidia-current

/usr/local/cuda/lib64

include /etc/ld.so.conf.d/*.conf

running ‘ldconfig -v | grep libcuda’ gives the following:

liad@monster:~$ sudo ldconfig -v | grep libcuda

	libcuda.so.1 -> libcuda.so.195.36.24

	libcudartemu.so.3 -> libcudartemu.so.3.0.14

	libcudart.so.3 -> libcudart.so.3.0.14

	libcuda.so.1 -> libcuda.so.195.36.24

it seems to me, everything should work… still I get the same error stated above, when trying to ‘make’ the SDK (using gcc 4.3.x).

Anyone?

ldconfig settings have no effect on compilation and linking behaviour. If libcuda is in a non-standard place, you will need to point the compiler to that place.

Sorry for the late reply, I had some issues with getting to the forums last few days.

OK, I see what you’re saying, but the question is, where to does the original driver package send libcuda.so to, if not to where the ubuntu package does? I can add symbolic links in the proper places. Can anyone state the location of their installed lib files?

For the drivers from nvidia’s site libcuda.so is in /usr/lib while for the default ubuntu 10.04 driver it’s in /usr/lib/nvidia-current if I’m not mistaking…

N.

Thank you, I’ll try creating a symbolic link and see what happens.

Nothing changed… :(

I remember encountering a few problems myself when using the ubuntu provided drivers. Fixed it by installing the drivers from nvidia’s site. I’ve outlined some steps to get it working an ubuntu 10.04 in this thread.

N.

Yeah, I was hoping to get it sloved without disabling the apt packages. Too bad Ubuntu decided to make a change like that with this driver version, it worked fine in the previous one. I eventually reverted to installing the latest driver from the NVIDIA .run package.

Thank you for the howto. I actually found it and used it before noticing your reply here Nico.

I managed to get it working without removing the Apt packages, but I did have to hack the makefiles.

Basically, I have both GCC4.3 and GCC4.4 installed. I installed CUDA into /opt/cuda, then created a directory under that (/opt/cuda/gcc43links). In that directory I created two symlinks: ‘gcc’ and ‘g++’ which link to /usr/bin/gcc-4.3 and /usr/bin/g+±4.3 respectively. Then I modified common.mk (watch out, there are two of these: one in NVIDIA_GPU_Computing_SDK/C/common/common.mk, the other in NVIDIA_GPU_Computing_SDK/shared – you need to modify BOTH) to set the GCC4.3 directory as the compiler binpath:

[codebox]# architecture flag for nvcc and gcc compilers build

CUBIN_ARCH_FLAG :=

CXX_ARCH_FLAGS :=

NVCCFLAGS := --compiler-bindir=/opt/cuda/gcc43links

LIB_ARCH := $(OSARCH)

[/codebox]

This makes stuff compile, but libcuda still won’t link, even if it’s on LD_LIBRARY_PATH… we need to fix that. Open up common.mk (both of them!) again, and change this (around ln 269):

[codebox]# static linking, we will statically link against CUDA and CUDART

ifeq ($(USEDRVAPI),1)

 LIB += -lcuda   ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} 

else

 ifeq ($(emu),1) [/codebox]

to:

[codebox]# static linking, we will statically link against CUDA and CUDART

ifeq ($(USEDRVAPI),1)

 LIB += -L/usr/lib/nvidia-current -lcuda   ${OPENGLLIB} $(PARAMGLLIB) $(RENDERCHECKGLLIB) $(CUDPPLIB) ${LIB} 

else

 ifeq ($(emu),1) [/codebox]

And now you should be able to build the examples! :)

I wouldn’t (and don’t) use the standard makefile for my own projects, though… quite frankly, it’s a convoluted mess…

Well, eventually I just installed the latest driver (now it’s 256.something?) and I’m running like this, with gcc 4.3.something. Works rather well for my needs :)

This really works, thanks … I also prefer not being forced to reinstall the default Ubuntu Nvidia driver, although I have done it in the past …

Thanks a lot… I am a new user and was getting lost with these problems… finally this forum helped a lot…thanks again