In Linux, if you have written your own dynamic link libraryProgramTo find these dynamic link libraries. If the setting is incorrect, 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 put in the variable LD_LIBRARY_PATH.
In this case, you can use the commandExportTo test temporarily to confirm whether the problem is:
Export LD_LIBRARY_PATH=/Usr/local/lib
Run the preceding command on the terminal and then run the executable file. If the file runs normally, this problem occurs.
The following problem is: the above practice is to set variables temporarily.LD_LIBRARY_PATHAt the next boot, all settings will no longer exist. How can I keep this value in LD_LIBRARY_PATH?
We can~ /. BashrcOr~ /. Bash_profileThe Export Statement is added. The former reads each login and each opening of the shell, and the latter reads only once upon login. My habit is to add~ /. BashrcIn, before the end of the file, you can use the following statement to make the settings take effect:
Export LD_LIBRARY_PATH= $LD_LIBRARY_PATH:/Usr/local/lib
After modification, remember to turn off the current terminal and open a new terminal to make the above configuration take effect.