linux 动态链接库查找方法;查找动态链接库位置;…
2019-12-06 16:01:29来源:博客园 阅读 ()
linux 动态链接库查找方法;查找动态链接库位置; LIBRARY_PATH 和 LD_LIBRARY_PATH 的区别;LD_LIBRARY_PATH and LD_RUN_PATH的区别;
今天配置之前项目的时候,发现有些动态链接库变了,想看看现在应用在使用哪些动态链接库的时候,进一步查了点资料;
下面针对linux动态链接库查找方法和动态链接库位置配置的过程进行记录:
LIBRARY_PATH 和 LD_LIBRARY_PATH 的区别: (参考链接)
LIBRARY_PATH is used by gcc before compilation to search directories containing static and shared libraries that need to be linked to your program. LD_LIBRARY_PATH is used by your program to search directories containing shared libraries after it has been successfully compiled and linked.
As pointed below, your libraries can be static or shared. If it is static then the code is copied over into your program and you don't need to search for the library after your program is compiled and linked. If your library is shared then it needs to be dynamically linked to your program and that's when LD_LIBRARY_PATH
comes into play.
LD_LIBRARY_PATH and LD_RUN_PATH 的区别: (参考链接)
LD_RUN_PATH is used for the link time resolution of libraries whilst LD_LIBRARY_PATH is used for run time resolution of libraries. LD_RUN_PATH Specifies the directories that are to be searched for libraries at both link and run time. LD_LIBRARY_PATH indicates to the dynamic loader to search the colon delimited paths for libraries required to execute the binary. LD_RUN_PATH is used by the linker to specify where to look for libraries only at run time. This differs ever so slightly from LD_LIBRARY_PATH in that this set of paths are not searched during link time.
动态链接库查找路径配置:
1. 可以使用上面 LD_LIBRARY_PATH 等环境变量进行配置;
2. 可以使用 /etc/ld.so.conf 全局配置文件,配置动态链接库运行时的搜索路径; 然后使用ldconfig命令,进行将/etc/ld.so.conf加载到ld.so.cache之中(需要root权限);
3. 然后使用:ldconfig -p | grep "your lib" 进行查找所需要动态链接库的位置;
4. 针对已有程序,可以使用 ldd "your bin" 进行直接看当前执行程序所需要的链接库的情况;
保持更新,转载请注明出处;更多内容,请关注 cnblogs.com/xuyaowen;
/etc/ld.so.conf.d/x86_64-linux-gnu.conf,多体系结构支持配置,以x86_64为例:
# Multiarch support /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
保持更新;
原文链接:https://www.cnblogs.com/xuyaowen/p/linux-so-library-path.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:git命令总结
- Linux系统如何设置开机自动运行脚本? 2020-06-11
- Linux指令和shell脚本 2020-06-11
- 适合开发者的最佳Linux发行版 2020-06-11
- RAID 1 软件实现(Linux 系统) 2020-06-10
- linux各级目录 2020-06-08
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash