Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

Tags:

I use gsl. After I compiled my .cpp file and run it, I faced with below error:

error while loading shared libraries: libgsl.so.0: cannot open shared object file: No such file or directory

I found same as this problem in: https://groups.google.com/forum/#!topic/cortex_var/6vluX7pP0Sk & Linux error while loading shared libraries: cannot open shared object file: No such file or directory & http://www.gnu.org/software/gsl/manual/html_node/Shared-Libraries.html

And I have done as in the above links wrote but the error is still remained. Can anyone help me?

like image 626
Abdolvahed Avatar asked Mar 06 '14 11:03

Abdolvahed


2 Answers

To make it work do the following steps

Start Borne Shell

$LD_LIBRARY_PATH= path to your gsl lib folder inside the gsl installation folder $export LD_LIBRARY_PATH 

now run your executable

It should work fine.

like image 188
Inquisitive Avatar answered Oct 13 '22 14:10

Inquisitive


First, you need to locate the file (libgsl.so.0). You can do this, for example, by using the find command:

sudo find / -name "libgsl.so.0" 

Let us assume, the file is located in /usr/local/lib. (If the file has not been found, install the corresponding package or download the source, build it and install it.) Now, you have two options:

(1) Quick & Dirty:

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib export LD_LIBRARY_PATH 

This adds the path of the library to an environment variable. The disadvantage of this option is, that it is only valid for the current session. It will not work for other users. It will not work once you log off and on again.

(2) Permanent:

Review your /etc/ld.so.conf. If /usr/local/lib is not listed there, add it. Now, run ldconfig to detect the shared object file and add it to some system-wide index.

like image 26
ManuelAtWork Avatar answered Oct 13 '22 14:10

ManuelAtWork