Under Linux, if you write your own dynamic link libraries and need to be called in other programs, you need to have these programs find these dynamic link libraries. If the settings are not correct, an error similar to the following occurs:
Test:error while loading shared libraries:libexampleso.so.0:cannot open Shared object file:no such file or directory
This is because the installation path of the dynamic link library (for example,/usr/local/lib) is not placed in the variable Ld_library_path.
At this point, you can use the command export to temporarily test to determine whether this problem:
Export Ld_library_path=/usr/local/lib
Run the above line command in the terminal and run the executable file, which is the problem if it works.
The next question is: The above practice, only temporary set variable ld_library_path , the next boot, all settings will no longer exist; How to keep this value in the Ld_library_path.
We can add the export statement to the ~/.BASHRC or ~/.bash_profile , which reads once every time the shell is logged on and every time it is opened, which is only read once on login. My custom is to add to the ~/.BASHRC , in the end of the file, you can use the following statement to make the setting effective:
Export Ld_library_path= $LD _library_path:/usr/local/lib
After the modification, remember to turn off the current terminal and reopen a new terminal so that the above configuration takes effect.
Reproduced from: http://www.cnblogs.com/waterlin/archive/2011/07/14/2106056.html