Linux:

1. 利用ldd查看可执行程序的依赖库

  1.  
  2. [root@~]# ldd /usr/local/php/bin/php
  3.  
    linux-vdso.so.1 => (0x00007fff753f5000
     
     

注:ldd通过调用动态链接器来获取可执行程序的依赖库,但是并不推荐在未知的可执行程序上执行业ldd来获取其依赖库,因为部分版本的ldd会直接通过调用该可执行程序来获取其依赖库,这存在安全风险。

如果某个依赖的库不存在,会打印类似“xxx.so not found”的提示。

2. 利用pmap工具查询未知的可执行程序的依赖库

  1.  
    [root@~]# objdump -p /usr/local/php/bin/php |grep NEEDED
  2.  
    NEEDED libcrypt.so.1
  3.  
    NEEDED librt.so.1
  4.  
    NEEDED libmysqlclient.so.18
  5.  
    NEEDED libmcrypt.so.4
  6.  
    NEEDED libiconv.so.2
  7.  
    NEEDED libcurl.so.4
  8.  
    NEEDED libm.so.6
  9.  
    NEEDED libdl.so.2
  10.  
    NEEDED libnsl.so.1
  11.  
    NEEDED libxml2.so.2
  12.  
    NEEDED libz.so.1
  13.  
    NEEDED libssl.so.10
  14.  
    NEEDED libcrypto.so.10
  15.  
    NEEDED libpthread.so.0
  16.  
    NEEDED libc.so.6
  17.  
    NEEDED libresolv.so.2

3. 利用pmap查看正在运行时的进程的依赖库

利用pldd工具既可以获取进程的内存映射信息,也可以获取进程的依赖共享库信息:

  1.  
    [root@~/software/pldd]# ps -ef|grep php-fpm
  2.  
    root 26534 1 0 2014 ? 00:01:34 php-fpm: master process (/usr/local/php-5.3.29/etc/php-fpm.conf)
  3.  
    nobody 26535 26534 0 2014 ? 00:00:04 php-fpm: pool www
  4.  
    nobody 26536 26534 0 2014 ? 00:00:05 php-fpm: pool www
  5.  
    root 30510 30324 0 00:39 pts/0 00:00:00 grep php-fpm
  6.  
    [root@~/software/pldd]# pmap 26534 |head
  7.  
    26534: php-fpm: master process (/usr/local/php-5.3.29/etc/php-fpm.conf)
  8.  
    0000000000400000 10452K r-x-- /usr/local/php-5.3.29/sbin/php-fpm
  9.  
    0000000001035000 76K rw--- /usr/local/php-5.3.29/sbin/php-fpm
  10.  
    0000000001048000 104K rw--- [ anon ]
  11.  
    0000000002a65000 3448K rw--- [ anon ]
  12.  
    000000311c600000 388K r-x-- /usr/lib64/libssl.so.1.0.1e
  13.  
    000000311c661000 2048K ----- /usr/lib64/libssl.so.1.0.1e
  14.  
    000000311c861000 16K r---- /usr/lib64/libssl.so.1.0.1e
  15.  
    000000311c865000 28K rw--- /usr/lib64/libssl.so.1.0.1e
  16.  

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 查看程序、进程的依赖库的方法的更多相关文章

  1. Linux 平台如何查看某个进程的线程数?

    Linux 平台如何查看某个进程的线程数?   三种方法:1. 使用top命令,具体用法是 top -H 加上这个选项,top的每一行就不是显示一个进程,而是一个线程. 2. 使用ps命令,具体用法是 ...

  2. windows查看所有进程:netstat -ano

    windows查看所有进程:netstat -ano ------------------------------------------------------------------------- ...

  3. linux与windows查看占用端口的进程ID并杀死进程

    有时候tomcat出现端口被占用,需要查出进程ID并杀死进程. 1.查找占用端口的进程ID(windows与linux一样  8005也可以加上引号   grep可以用findstr替换) 6904就 ...

  4. Linux 和 Windows 查看当前运行的 python 进程及 GPU、CPU、磁盘利用率

    目录 查看当前 python 进程 Linux Windows 查看 GPU 利用率 Linux Windows Linux CPU 利用率 Linux 磁盘利用率 查看当前 python 进程 Li ...

  5. Linux及Windows查看占用端口的进程

    想必大家在部署环境启动服务的时候,会遇到服务起不起来的问题,看日志,说是端口被占用了. 有的时候,我们不想改端口,那么,就需要去查看到底是哪个应用把这个端口给占用了,然后干掉它即可. 下面分别列举li ...

  6. windows程序查看可以行文件依赖库

    通常在做windows下开发程序,发布的时候需要同时打包一些依赖库:我们可以通过工具直接查看需要发布的程序依赖的程序,这样可以方便快捷的打包程序 这里我们推荐使用:dependencywalker 下 ...

  7. Linux有问必答:Linux上如何查看某个进程的线程

    原创:LCTT https://linux.cn/article-5633-1.html 译者: GOLinux本文地址:https://linux.cn/article-5633-1.html201 ...

  8. Windows 查看程序占用的端口

    一. 查看所有进程占用的端口  在开始-运行-cmd,输入:netstat –ano可以查看所有进程 二.查看占用指定端口的程序  当你在用tomcat发布程序时,经常会遇到端口被占用的情况,我们想知 ...

  9. Linux 和 Windows 查看 CUDA 和 cuDNN 版本

    目录 Linux 查看 CUDA 版本 查看 cuDNN 版本 Windows 查看 CUDA 版本 查看 cuDNN 版本 References Linux 查看 CUDA 版本 方法一: nvcc ...

随机推荐

  1. day11 十一、函数对象,名称空间,作用域,和闭包

    一.函数对象 1.函数对象:函数名存放的就是函数的地址,所以函数名也是对象,称之为函数对象 a = 10 print(a,id(a)) def fn(): num = 10 print('fn fuc ...

  2. 精彩看点 | GIAC大会PPT+视频合集全量放送!

    GIAC是中国互联网技术领域的行业盛事,每年从互联网架构最热门的系统架构设计.人工智能.机器学习.工程效率.区块链.分布式架构等领域甄选前沿有典型代表的技术创新及研发实践的架构案例,分享他们在本年度最 ...

  3. HQL之动态分区调整

    动态分区插入可以基于查询语句分出出要插入的分区名称.比如,下面向分区表插入数据的SQL: insert into table chavin.emp_pat partition(dname,loc) s ...

  4. iOS-方法之+ initialize 与 +load

    Objective-C 有两个神奇的方法:+load 和 +initialize,这两个方法在类被使用时会自动调用.但是两个方法的不同点会导致应用层面上性能的显著差异. 一.+ initialize ...

  5. [daily][dpdk] 内核模块(网卡驱动)无法卸载

    由于程序的异常退出, 内核的引用计数没有被清除(我猜的). 所以驱动不能被卸载掉, 强制也不行. 如下: [root@localhost ~]# insmod /opt/scorpion/KingKo ...

  6. Copycat - StateMachine

    看下用户注册StateMachine的过程, CopycatServer.Builder builder = CopycatServer.builder(address); builder.withS ...

  7. unity插件,从一段文字中提取中文并去重

    using System.Collections.Generic; using System.Text.RegularExpressions; using UnityEditor; using Uni ...

  8. Asp.net Mvc action返回多个模型实体给view

    1.controller中action代码: public class HomeController : Controller { public ActionResult Detail(int id) ...

  9. 【F12】谷歌浏览器--前台效果可以在不访问服务器的前提下直接改样式看效果是否是预期值。

    F12-前台效果可以在不访问服务器的前提下直接改样式看效果是否是预期值. 1.Element---页面所有元素,通过它可以做selenium的元素定位,删除页面元素,增加页面属性(通过增加页面属性便于 ...

  10. centos7安装webmin

    安装webmin准备centos7系统1.下载http://download.webmin.com/download/yum/选择:webmin-1.700-1.noarch.rpm 安装包 wget ...