HOMEBREW Uninstall: FaiLED to Locate Homebrew! Wrong Flyinginthe

2023-01-19   ES  

linux shared library: ld_library_path and ld.so.conf_ just loved it_Sina blog

linux shared library: ld_library_path and ld.so.conf
    (2009-07-28 10:46:39)

Reprinted ▼
miscellaneous talk
Classification: Operating System

Linux environment variable name, this environment variable is mainly used to specify other paths except the default path when the search sharing library (dynamic link library). (Find this path before the default path)
When transplantation, you often need to use some specific dynamic libraries, and these compiled dynamic libraries are placed in the directory we created by ourselves. At this time, these directory can be set to LD_Library_Path.
When the dynamic link of the function is executed .so, if this file is not in the default directory, ‘/usr/local/lib’ and ‘/usr/lib’.
So you need to specify environment variables ld_library_path
If you need to add a new path name to the existing environment variables now, the following ways:
ld_library_path = newdirs: $ ld_library_path.

How does


Linux run? Below Linux, the search and loading of the shared library is implemented by /lib/ld.so. LD.SO looks for the shared library used in the standard road (/lib,/usr/lib).

but if the shared library you need to use is in the non -standard road scripture, how does LD.SO find it?

At present, Linux is generally used to add the non -standard path to the /etc/ld.so.conf, and then run ldconfig to generate /etc/ld.so.cache. When LD.SO loads the shared library, it will be found from ld.so.cache.

Traditionally, Linux’s ancestor Unix also has an environmental variable: ld_library_path to handle the shared library of the non -standard path. When LD.SO loads the shared library, you will also find the way the channel set up in this variable.

    export LD_LIBRARY_PATH

but there are many voices advocating to avoid using LD_Library_path variables, especially as global variables. These sounds 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 the run -time path through -R <PATH> options when compiling.

1. Adding things to/lib and/usr/lib, there is no need to modify the /etc/ld.so.conf, but after the completion

2. When you want to add things to the above two directory, be sure to modify /etc/ld.so.conf, and then call ldconfig, otherwise you will not find it
For example, install a mysql to/usr/local/mysql, mysql has a lot of Library under/usr/local/mysql/lib. Local/mysql/lib, after saving LDCONFIG, the new Library can be found when the program is running.

3. If you want to put LIB outside these two directory, but do not want to add things to /etc/ld.so.conf (or have no permissions to add things). That’s it, it is Export a global variable ld_library_path, and then you will go to this directory to find library when running the program. Generally speaking, this is just a temporary solution that uses it when there is no permissions or temporary needs.

4. These things that LDConfig do are related to the running program, which has nothing to do with compilation. When compiling, you should add -l to add, don’t be confused.

5. In short, no matter what changes in library, it is best to ldconfig, otherwise there will be some unexpected results. It won’t take too much time, but it will save a lot of things.

ld_library_path this environment variable is the most familiar with everyone, it tells Loader: what catalogs can be found in what catalogs can be found. You can set multiple search directory, which are separated by colonies between these directory. Under Linux, another way is also provided to complete the same features. You can add these directory to /etc/ld.so.conf, and then call LDConfig. Of course, this is the global effectiveness within the system, while the environment variable is only effective for the current shell. According to the convention, unless you indicate the above method, Loader will not find a shared library in the current directory, just as shell will not find executable files at present.

There are many ways to determine the


library search path. LD_Library_Path is just one of them. Such as compiling the command line RPATH parameters. LD_Run_Path environment variables during connection. /lib,/usr/lib standard directory. Dynamic connector cache /etc/ld.so.conf.

posted on
2013-02-01 14:24 
lexusRead () Comment ()

Reprinted: https://www.cnblogs.com/lexus/archive/2013/02/01/2888956.html


Related Posts

Use Ado+Access for database operation

[LCA] LCA’s tarjan writing POJ1330

LINUX system installation Oracle11G database through docker

network programming IP address

HOMEBREW Uninstall: FaiLED to Locate Homebrew! Wrong Flyinginthe

Random Posts

Create a custom function in mysql — divide a certain field with a comma and remove the first data

httpcomponents 4.5.2 Simple use

Caption that Java thread is necessary for dead locks

RecyclerView list Load the picture to refresh the flashing problem Bigsea

Connect the database with ThinkPHP and test whether the connection is successful