2015-10-17 122 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