In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
What are the three practical methods to solve the problem of Linux dynamic library dependence? aiming at this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Overview
Usually when compiling and installing a certain software, if you customize some installation directories, you may not be able to find the dynamic library after installation. Here are the ideas and three solutions.
Train of thought
Generally speaking, the dynamic library that the program depends on has been compiled through the make command, and the dynamic library has been installed to a path of the system through the make install command. If the dynamic library is not found, it depends on whether this path is included in the system default search path for the dynamic library. If not, it will prompt you that the dynamic library cannot be found. The following three methods are solved according to the previous analysis.
Method 1: modify the LD_LIBRARY_PATH environment variable
Features: this method mainly deals with temporary dynamic library loading, after the LD_LIBRARY_PATH environment variable is modified, it can only be effective for the current user.
The role of LD_LIBRARY_PATH: this environment variable is used to specify a path other than the system default path when looking for dynamic link libraries during program loading and running. Note that the path specified in LD_LIBRARY_PATH will be found before the system default path.
Specific steps:
1. Find the path where the dynamic library is located: sudo find /-name "[dynamic library name]"
2. Open the ~ / .bash_profile file
3. Add: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH: [absolute path where the dynamic library is located] in the file *.
4. Source ~ / .bash_profile
Method 2: modify / etc/ld.so.conf configuration file
Features: effective for all users. Not every operating system has this configuration file, just Ubuntu systems.
The function of / etc/ld.so.conf: record the path when looking for dynamic link libraries when the program is loaded and running.
Specific steps:
1. Find the path where the dynamic library is located: sudo find /-name "[dynamic library name]"
2. Open / etc/ld.so.conf file: sudo vi / etc/ld.so.conf
3. Add the absolute path of the dynamic library on the * line
4. Reload / etc/ld.so.conf file: sudo ldconfig-v
Method 3: create soft connections for dynamic libraries (recommended)
Features: let all users take effect; and universal, as long as it is a Linux type of operating system, will go to the / usr/lib directory to find dynamic libraries.
Specific steps:
1. Find the path where the dynamic library is located: sudo find /-name "[dynamic library name]"
2. Create a dynamic library soft link: ln-s [dynamic library] [soft link to be created]
Note:
1. Use an absolute path when creating a soft connection. If you use a relative path, it will only be valid in the current path, and the soft connection cannot be found in other paths.
2. It is not recommended to replace ln-s with cp. Reason: when the dynamic library is upgraded, it may cause the version of the dynamic library to be inconsistent or the linked old version.
The above mainly talks about three methods to create dynamic libraries, of which ln-s mode is more commonly used.
What are the three practical ways to solve the problem of Linux dynamic library dependence? the answers are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.