"/usr/bin/ld: cannot find -lcudart"

Make a symbolic link to libcuda where ld is searching it.

sudo ln -s /usr/local/cuda/lib64/libcudart.so /usr/lib/libcudart.so

LD_LIBRARY_PATH is used to modify the behaviour of the ldconfig and related tools when looking for the libraries, at execution time.

The ld linker tool doesn't use this variable. If you want to use a library located in a non-standard directory, you have to use the -L parameter of the command, like this :

ld -lcuda -L/usr/local/cuda/lib64

If you have downloaded and existing project and doesn't know how to modify the existing Makefile(s) without breaking the whole compilation, you can run make the following way :

export LDFLAGS=-L/usr/local/cuda/lib64
make

The variable LDFLAGS (which may be also defined into the Makefile), is used to pass specific arguments to the linker (ld) when launched by the compilation intructions.


You can make links instead of adding the paths:

ln -s /usr/local/cuda/lib64/libcudart.so /usr/local/lib/
ln -s /usr/local/cuda/lib64/libcudart.a /usr/local/lib/