Linux和windows 查看程序、进程的依赖库的方法
Linux:
1. 利用ldd查看可执行程序的依赖库
- [root@~]# ldd /usr/local/php/bin/php
- linux-vdso.so.1 => (0x00007fff753f5000
注:ldd通过调用动态链接器来获取可执行程序的依赖库,但是并不推荐在未知的可执行程序上执行业ldd来获取其依赖库,因为部分版本的ldd会直接通过调用该可执行程序来获取其依赖库,这存在安全风险。
如果某个依赖的库不存在,会打印类似“xxx.so not found”的提示。
2. 利用pmap工具查询未知的可执行程序的依赖库
- [root@~]# objdump -p /usr/local/php/bin/php |grep NEEDED
- NEEDED libcrypt.so.1
- NEEDED librt.so.1
- NEEDED libmysqlclient.so.18
- NEEDED libmcrypt.so.4
- NEEDED libiconv.so.2
- NEEDED libcurl.so.4
- NEEDED libm.so.6
- NEEDED libdl.so.2
- NEEDED libnsl.so.1
- NEEDED libxml2.so.2
- NEEDED libz.so.1
- NEEDED libssl.so.10
- NEEDED libcrypto.so.10
- NEEDED libpthread.so.0
- NEEDED libc.so.6
- NEEDED libresolv.so.2
3. 利用pmap查看正在运行时的进程的依赖库
利用pldd工具既可以获取进程的内存映射信息,也可以获取进程的依赖共享库信息:
- [root@~/software/pldd]# ps -ef|grep php-fpm
- root 26534 1 0 2014 ? 00:01:34 php-fpm: master process (/usr/local/php-5.3.29/etc/php-fpm.conf)
- nobody 26535 26534 0 2014 ? 00:00:04 php-fpm: pool www
- nobody 26536 26534 0 2014 ? 00:00:05 php-fpm: pool www
- root 30510 30324 0 00:39 pts/0 00:00:00 grep php-fpm
- [root@~/software/pldd]# pmap 26534 |head
- 26534: php-fpm: master process (/usr/local/php-5.3.29/etc/php-fpm.conf)
- 0000000000400000 10452K r-x-- /usr/local/php-5.3.29/sbin/php-fpm
- 0000000001035000 76K rw--- /usr/local/php-5.3.29/sbin/php-fpm
- 0000000001048000 104K rw--- [ anon ]
- 0000000002a65000 3448K rw--- [ anon ]
- 000000311c600000 388K r-x-- /usr/lib64/libssl.so.1.0.1e
- 000000311c661000 2048K ----- /usr/lib64/libssl.so.1.0.1e
- 000000311c861000 16K r---- /usr/lib64/libssl.so.1.0.1e
- 000000311c865000 28K rw--- /usr/lib64/libssl.so.1.0.1e
1.查看依赖的库:
objdump -x xxx.so | grep NEEDED
2.查看可执行程序依赖的库:
objdump -x 可执行程序名 | grep NEEDED
3.查看缺少的库:
ldd xxx.so
windows:
有时候我们想查看一个exe引用了哪些动态库,或者我们想看某个动态库包含哪些接口函数,这个时候可以使用dumpbin.exe工具:
1.输入Dumpbin -imports calldll.exe查看它的输入信息,可以看到它加载了***.dll
2.输入dumpbin –exports dlltest.dll,列出导出函数
开始->所有程序->Microsoft Visual Studio 2010->Visual Studio Tools ->“Visual Studio 命令提示(2010)”后,
就像普通的cmd一样的命令行环境,就可以正常使用VS的一些工具,其中就包括dumpbin。
输入如下命令,查看dll信息:
D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>
dumpbin -exports D:\WorkSpace\DLLTutorial\Debug\DLLTutorial.dll
\dumpbin /dependents your-file.dll
1.输入Dumpbin -imports calldll.exe查看它的输入信息,可以看到它加载了***.dll
2.输入dumpbin –exports dlltest.dll,列出导出函数
/DEPENDENTS:
查看依赖项; 如: dumpbin /dependents vlc.exe
ps:1. 如果有Image has the following delay load dependencies,列出的为 运行时动态加载的dll。
2. 如果有Image has the following dependencies,列出的为载入程序时加载的dll。
windows下,进程查看器(ProcessExplorer)可以用来查看进程(实时运行)依赖的dll文件;DependencyWalker可以用来查看dll或exe依赖的dll文件。
linux下,ldd可以用来查看bin文件或dll文件依赖的dll.
用来查看链接库的依赖关系的软件,名称为:Dependency Walker.
它的官方网站如下:
http://www.dependencywalker.com/
关于Dependency Walker的介绍:
Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules. Another view displays the minimum set of required files, along with detailed information about each file including a full path to the file, base address, version numbers, machine type, debug information, and more.
Dependency Walker is also very useful for troubleshooting system errors related to loading and executing modules. Dependency Walker detects many common application problems such as missing modules, invalid modules, import/export mismatches, circular dependency errors, mismatched machine types of modules, and module initialization failures.
Dependency Walker runs on Windows 95, 98, Me, NT, 2000, XP, 2003, Vista, 7, and 8. It can process any 32-bit or 64-bit Windows module, including ones designed for Windows CE. It can be run as graphical application or as a console application. Dependency Walker handles all types of module dependencies, including implicit, explicit (dynamic / runtime), forwarded, delay-loaded, and injected. A detailed help is included.
Linux和windows 查看程序、进程的依赖库的方法的更多相关文章
- Linux 平台如何查看某个进程的线程数?
Linux 平台如何查看某个进程的线程数? 三种方法:1. 使用top命令,具体用法是 top -H 加上这个选项,top的每一行就不是显示一个进程,而是一个线程. 2. 使用ps命令,具体用法是 ...
- windows查看所有进程:netstat -ano
windows查看所有进程:netstat -ano ------------------------------------------------------------------------- ...
- linux与windows查看占用端口的进程ID并杀死进程
有时候tomcat出现端口被占用,需要查出进程ID并杀死进程. 1.查找占用端口的进程ID(windows与linux一样 8005也可以加上引号 grep可以用findstr替换) 6904就 ...
- Linux 和 Windows 查看当前运行的 python 进程及 GPU、CPU、磁盘利用率
目录 查看当前 python 进程 Linux Windows 查看 GPU 利用率 Linux Windows Linux CPU 利用率 Linux 磁盘利用率 查看当前 python 进程 Li ...
- Linux及Windows查看占用端口的进程
想必大家在部署环境启动服务的时候,会遇到服务起不起来的问题,看日志,说是端口被占用了. 有的时候,我们不想改端口,那么,就需要去查看到底是哪个应用把这个端口给占用了,然后干掉它即可. 下面分别列举li ...
- windows程序查看可以行文件依赖库
通常在做windows下开发程序,发布的时候需要同时打包一些依赖库:我们可以通过工具直接查看需要发布的程序依赖的程序,这样可以方便快捷的打包程序 这里我们推荐使用:dependencywalker 下 ...
- Linux有问必答:Linux上如何查看某个进程的线程
原创:LCTT https://linux.cn/article-5633-1.html 译者: GOLinux本文地址:https://linux.cn/article-5633-1.html201 ...
- Windows 查看程序占用的端口
一. 查看所有进程占用的端口 在开始-运行-cmd,输入:netstat –ano可以查看所有进程 二.查看占用指定端口的程序 当你在用tomcat发布程序时,经常会遇到端口被占用的情况,我们想知 ...
- Linux 和 Windows 查看 CUDA 和 cuDNN 版本
目录 Linux 查看 CUDA 版本 查看 cuDNN 版本 Windows 查看 CUDA 版本 查看 cuDNN 版本 References Linux 查看 CUDA 版本 方法一: nvcc ...
随机推荐
- C#中字符串转换为计算公式(自定义公式的计算)
第一种解决方案 第一种也是功能最强大的一种,可以使用Eval函数,像在Java中一样强大,几乎所有的运算符都可以实现,包括四则运算,与或非等. 添加COM引用: private void button ...
- 新一代.NET平台三大框架的定位
这是今天坐公交时继续阅读 Virtual Panel: What's Next for .NET? 这篇采访报道的收获. 新一代.NET平台的三大框架是:.NET Core, .NET Framewo ...
- 进程池的同步方法 pool.apply
from multiprocessing import Pool,Process def f1(n): print(n) return n*n if __name__ == "__main_ ...
- JavaScript中的Array类型详解
与其他语言中的数组的区别: 1.JavaScript数组的每一项都可以保存任何类型的数据,一个数组的数组元素可以是不同类型的数据. 2.数组的大小是动态调整的,可以随着数据的添加自动的增长. 1.两种 ...
- pytorch的一些基本操作
(1)生成一个未初始化的tensor import torch x = torch.Tensor(5,3) print(x) (2)随机初始化一个tensor y = torch.randn(5,3) ...
- wap手机端实现上传图片流程
实现图片上传使用了WeUI uploader插件 WeUI:是一套同微信原生视觉体验一致的基础样式库,为微信Web开发量身设计 流程:图片上传用到了FileReader,FormData,用这两个基本 ...
- Chap4:探究操作系统[The Linux Command Line]
1 learn some more commands: (1) ls-List directory contents (2) file -Determine file type (3) less-Vi ...
- iPhone开发之使用NSUserDefaults存储数据
NSUserDefaults是什么,有什么用处 对于应用来说,每个用户都有自己的独特偏好设置,而好的应用会让用户根据喜好选择合适的使用方式,把这些偏好记录在应用包的plist文件中,通过NSUserD ...
- LeetCode 496 Next Greater Element I 解题报告
题目要求 You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset ...
- kafka后台启动的命令
kafka如果直接启动会出现问题,就是信息会打印在控制台,就会出现在控制台. 然后关闭窗口,kafka随之关闭,然后启动以下的命令就可以实现. ./kafka-server-start.sh ../c ...