How to set environment variable LD_LIBRARY_PATH? linux LD_LIBRARY_PATH

I modified the file .bash_profile :
add the below lines to .bash_profile:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
and then in terminal type:
#source ~/.bash_profile,
at the "make " step ,no error occured,
but,when execute the examples from SDK, errors occured:cannot find libcudart.so.
It likes that compiler can not find cuda library!

who can help me ?
Thanks !My English is poor ,hope you understand me!

E-mail:zhuyating@163.com

Hi,

try

TCSH: setenv LD_LIBRARY_PATH=YOURPATH

BASH: export LD_LIBRARY_PATH=YOURPATH

With most modern distribution (works on Debian, Ubuntu and openSUSE), the loading of shared library is controlled in configuration files ( namely “/etc/ld.so.conf” and all conf files in “/etc/ld.so.conf.d”) :[list=1]

Go in directory " /etc/ld.so.conf.d "

As root (for exemple " sudo nano ", or whatever) add a file named " cuda.conf "

Type in the path to the cuda library " /usr/local/cuda/lib ", and save the file

As root run " /sbin/ldconfig " to update

Now, when you run the programs, they will automatically fetch the correct dynamically linked .SO file.

(To see it in action, type "ldd " + the name of the program. LDD will list all the required shared libraries, and which .SO file it has found for them).

Thanks a lot for all replies!

The complete error I encountered when seting environment variable LD_LIBRARY_PATH:

./matrixMul:error while loading shared libraries :/usr/lib/libcudart.so:cannot restore segment prot after reloc:Permission denial

The error is due to SELinux.
Disable it or give the proper permission to the library with chcon

Thanks for reply,
let me try!

:) :)
Thank you very much!
My problem has been resolved!
The error is due to SELinux!
Disabled it and then the SDK samples can be run correctly!

…aaargh! i feel dumb! I think i was using x86_64 version of the tool kit on 32bit. uninstalled and re-installed 32 bit toolkit and things work fine. although a different error now. /usr/local/cuda/lib has libcudart.so but no libcuda.so but sample apps like simpleTextureDrv uses the the USEDRVAPI=1 and that tries to use -lcuda instead of -lcudart and then fails.

Thanks for all the replies

libcuda.so is part of the driver package, not the CUDA toolkit.