Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of loading search path in Linux dynamic Library

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the Linux dynamic library load search path example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

The dynamic linker ld.so searches for the desired dynamic shared libraries in the following order:

The path specified by DT_RPATH in the dynamic segment of the 1.ELF executable file. This is actually set by a less commonly used but more practical method: when compiling the object code, you can add the link parameter "- Wl,-rpath" to gcc/g++ to specify the dynamic library search path

2. Dynamic library search path specified by environment variable LD_LIBRARY_PATH

The path to the dynamic library cached in 3./etc/ld.so.cache, if ld.so.cache is supported. This can be changed by modifying the dynamic library search path specified in the configuration file / etc/ld.so.conf

4. Default dynamic library search path / lib or / lib64

5. Default dynamic library search path / usr/lib or / usr/lib64

Simple example

Root@4c9f329b2677:/home/test# cat printf.cpp

# include

Void Print ()

{

Std::cout

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report