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 ...
随机推荐
- 关于启动VS2012时,提示Web4.0尚未在网络服务器上注册的解决办法!
VS2012在没有Web服务器上注册的问题,网上有很多博客. 开始我就是遇到这个问题,在网上试了几个办法,确实都还可以.但是相比之下有的需要设置DOS,进行安装.exe. 这种方法其实相比直接安装补丁 ...
- python-Beautiful rose
热爱python,热爱生活,python需要浪漫,让我带大家走进浪漫的国度...写的不好的地方请大佬指教 import turtle import time class Rose: def __ini ...
- c# 主窗体更新子窗体 进程间通信
1.窗体间数据传输 主窗体连续不断更新给子窗体 本文章来源于网络 年代久远 如有侵犯 请联系删除 1.通过 在windows form之间传值,我总结了有四个方法:全局变量.属性.窗体构造函数和de ...
- hbase与hive集成:hive读取hbase中数据
1.创建hbase jar包到hive lib目录软连接 hive需要jar包: hive-hbase-handler-0.13.1-cdh5.3.6.jar zookeeper-3.4.5-cdh5 ...
- Python使用xml.dom解析xml
在菜鸟教程上找了个关于电影信息的xml类型的文档,用python内置的xml.dom来解析提取一下信息. 先复习一下xml概念: XML 指可扩展标记语言(EXtensible Markup Lang ...
- C和C指针小记(八)-操作符、左值右值
1.移位操作符 移位操作符分为左移操作符(<<)和右移操纵符(>>) 对于无符号数:左右位移操作都是逻辑位移 对于有符号数:到底是采用逻辑位移还是算术位移取决于编译器.如果一个 ...
- SQL复制数据表 (select * into 与 insert into)
select * into 目标表名 from 源表名 insert into 目标表名(fld1, fld2) select fld1, 5 from 源表名 以上两句都是将 源表 的数据插入到 目 ...
- Java向服务端转身 系统平台所对应的机器语言 虚拟CPU的机器语言字节码 bytecode
小结: 1.虚拟CPU的模拟器:java虚拟机 JVM Java将虚拟机(VM)作为插件集成到浏览器中,将编译后的Java程序(Applet)在虚拟机上运行,这种技术 当初是为了增强浏览器的功能. J ...
- PHP之流程控制
nest 嵌套 the curly braces 花括号 colon syntax 冒号语法 PHP三种if判断的写法 写法一: if(true){ }else if(){ }else if(){ } ...
- 2016年蓝桥杯省赛A组c++第3题(图论)
/* 有一个含有10个格子的图形,现用0~9填充,连续的数不能填充在相邻的格子中(包括对角线相邻). 现每个数只能填写一次,问有多少种填充方法? 0111 1111 1110 (1表示有格子,0表示没 ...