2015-10-17 43 views
3

鉴于Cygwin可执行文件,我如何找出它依赖的所有dll?
对于由系统可执行程序加载器加载的库,我可以使用类似depends(又名Dependency Walker)的工具,但我不知道如何跟踪程序试图使用加载库动态加载的dll。如何找出Cygwin程序的dll依赖项?

我的目标是能够获取为Cygwin平台构建的程序的最小依赖性,以使其工作可移植,而不需要Cygwin所不会使用的所有东西(一些基本的命令行实用程序,手册页等等。)。

任何帮助表示赞赏!

回答

4

其中一个将做到这一点。请注意,您可以忽略Windows文件夹中的任何内容,因为这些DLL将位于任何Windows系统上。

$ ldd /bin/grep 
     ntdll.dll => /Windows/SYSTEM32/ntdll.dll (0x77200000) 
     kernel32.dll => /Windows/system32/kernel32.dll (0x76fe0000) 
     KERNELBASE.dll => /Windows/system32/KERNELBASE.dll (0x7fefd090000) 
     cygwin1.dll => /usr/bin/cygwin1.dll (0x180040000) 
     cygiconv-2.dll => /usr/bin/cygiconv-2.dll (0x3ffb00000) 
     cygintl-8.dll => /usr/bin/cygintl-8.dll (0x3ffae0000) 
     cygpcre-1.dll => /usr/bin/cygpcre-1.dll (0x3ff850000) 

或者

$ cygcheck /bin/grep 
C:\cygwin64\bin\grep.exe 
    C:\cygwin64\bin\cygwin1.dll 
    C:\Windows\system32\KERNEL32.dll 
     C:\Windows\system32\API-MS-Win-Core-RtlSupport-L1-1-0.dll 
     C:\Windows\system32\ntdll.dll 
     C:\Windows\system32\KERNELBASE.dll 
     C:\Windows\system32\API-MS-Win-Core-ProcessThreads-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Heap-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Memory-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Handle-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Synch-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-File-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-IO-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-ThreadPool-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-LibraryLoader-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-NamedPipe-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Misc-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-SysInfo-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Localization-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-ProcessEnvironment-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-String-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Debug-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-ErrorHandling-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Fibers-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Util-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Core-Profile-L1-1-0.dll 
     C:\Windows\system32\API-MS-Win-Security-Base-L1-1-0.dll 
    C:\cygwin64\bin\cygiconv-2.dll 
    C:\cygwin64\bin\cygintl-8.dll 
    C:\cygwin64\bin\cygpcre-1.dll 
+0

这些列表包括那些可能被动态(可选的)加载的DLL?如果不是,我们怎么能列出它们呢? – Fr0stBit

+0

@艺术家你在说什么?根据定义,所有动态链接库都是动态的 –

+1

并非所有DLL在程序启动时都由程序加载程序加载。例如,一些可以在运行时通过使用诸如Windows中的LoadLibrary之类的API来加载。 – Fr0stBit