Question: Cannot open shared object File:no such file or directory failed
Method: Make a link and put it in the/usr/lib.
such as: Ln-s/usr/local/mysql/lib/libmysqlclient.so.16/usr/lib/
Better Way:
When Linux is running, how to manage shared libraries (*.so). Under Linux, the search and load of shared libraries is implemented by/lib/ld.so. ld.so searches the standard path (/lib,/usr/lib) for shared libraries that are used by applications.
However, if the shared library you need is in a non-standard path, how can ld.so find it?
At present, the common practice of Linux is to add non-standard paths to/etc/ld.so.conf and then run Ldconfig to generate/etc/ld.so.cache. When ld.so loads a shared library, it looks for it from the Ld.so.cache.
Traditionally, Linux's predecessor, Unix, also has an environment variable: Ld_library_path to handle the shared library of non-standard paths. When ld.so loads a shared library, it also looks up the path set by the variable.
Ld_library_path= $LD _library_path:./lib
Export Ld_library_path
However, there are many voices advocating avoiding the use of Ld_library_path variables, especially as global variables. These voices are:
* Ld_library_path is not the answer-http://prefetch.net/articles/linkers.badldlibrary.html
* Why Ld_library_path is bad-http://xahlee.org/unixresource_dir/_/ldpath.html
* Ld_library_path-just say no-http://blogs.sun.com/rie/date/20040710
Another way to solve this problem is to specify Run-time path at compile time through the-r<path> option.
1. To/lib and/usr/lib inside add things, is not to modify the/etc/ld.so.conf, but after the end to adjust the ldconfig, or the library will not find
2. When you want to add something to the top two directories, be sure to modify the/etc/ld.so.conf, and then call Ldconfig, or you will not find it.
For example, install a MySQL to/usr/local/mysql,mysql there are a lot of library under/usr/local/mysql/lib, then need to add a line under/etc/ld.so.conf/usr/local/ Mysql/lib, after saving Ldconfig, the new library can be found when the program is running.
3. If you want to put Lib in the two directories, but do not want to add things in the/etc/ld.so.conf (or do not have permission to add things). That can also be, is export a global variable ld_library_path, and then run the program will go to this directory to find the LIBRARY. This is generally a temporary solution that is used when there is no authority or temporary need.
4. These things that ldconfig do are related to the running of the program, with no relationship to compile. The time to compile or add-l is to add, do not confuse.
5. In short, it is no matter what has been done about the library changes, it is best to ldconfig, otherwise there will be some unexpected results. It won't take much time, but it will save a lot of things.
Ld_library_path is the most familiar of the environment variables, and it tells loader which directories can find shared libraries. You can set up multiple search directories separated by colons. Under Linux, there is another way to do the same, you can add these directories to/etc/ld.so.conf, and then call Ldconfig. Of course, this is system-wide and globally valid, and environment variables are only valid for the current shell. By convention, unless you indicate in this way, loader is not going to look for a shared library in the current directory, just as the shell does not currently look for an executable file.