Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the environmental variable LD_LIBRARY_PATH in linux

I have first executed the command: export LD_LIBRARY_PATH=/usr/local/lib

Then I have opened .bash_profile file: vi ~/.bash_profile. In this file, I put:

LD_LIBRARY_PATH=/usr/local/lib export LD_LIBRARY_PATH 

Then if the terminal is closed and restarted, typing echo $LD_LIBRARY_PATH displays no result.

How to set the path permanently?

like image 307
singha Avatar asked Nov 17 '12 08:11

singha


People also ask

What is Ld_library_path environment variable?

The LD_LIBRARY_PATH environment variable tells Linux applications, such as the JVM, where to find shared libraries when they are located in a different directory from the directory that is specified in the header section of the program.

How do I change the library path in Linux?

How do I set the Library path under Linux operating systems? You need to use ldconfig config file and ldconfig command which creates the necessary links and cache to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld. so.


1 Answers

You should add more details about your distribution, for example under Ubuntu the right way to do this is to add a custom .conf file to /etc/ld.so.conf.d, for example

sudo gedit /etc/ld.so.conf.d/randomLibs.conf 

inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example

/home/linux/myLocalLibs 

remember to add only the path to the dir, not the full path for the file, all the libs inside that path will be automatically indexed.

Save and run sudo ldconfig to update the system with this libs.

like image 140
user1824407 Avatar answered Oct 14 '22 00:10

user1824407