dumpbin /dependents
將允許您確定模塊(EXE或DLL)是否依賴於Visual C++庫DLL(以及這些DLL的哪些版本和風格 - 調試或發佈)。例如,使用Visual C++ 2013 ...
當你/MD
編譯,你的模塊依賴於零售msvcr120.dll:
>cl /MD /nologo test.cpp
test.cpp
>dumpbin /dependents test.exe | findstr dll
MSVCR120.dll
KERNEL32.dll
當你/MDd
編譯,你的模塊取決於調試msvcr120d .dll文件:
>cl /MDd /nologo test.cpp
test.cpp
>dumpbin /dependents test.exe | findstr dll
MSVCR120D.dll
KERNEL32.dll
當你與/MT
或/MTd
編譯,你的模塊不依賴於任何CRT DLL:
>cl /MT /nologo test.cpp
test.cpp
>dumpbin /dependents test.exe | findstr dll
KERNEL32.dll
>cl /MTd /nologo test.cpp
test.cpp
>dumpbin /dependents test.exe | findstr dll
KERNEL32.dll
當您靜態鏈接Visual C++庫時,通常無法確定零售庫或調試庫是否已鏈接(通常,您無法確定是否鏈接了任何Visual C++庫)。如果您的模塊具有PDB,那麼您通常可以根據模塊中存在的源文件信息和函數來確定鏈接的內容。 (2條記錄:[1]我的test.cpp文件是一個簡單的C Hello,World!程序,如果它動態地鏈接了其他的Visual C++庫,dumpbin /dependents
也會報告它們。[2] dumpbin /dependents
與DLLs )
'dumpbin'和'link'不能通過Visual Studio分發(https://www.visualstudio.com/en-us/productinfo/2015-redistribution-vs),所以它的實用程序僅限於開發者的結局;我如何通過C或C++獲得類似的查詢?我很好地使用操作系統庫來做到這一點,但我需要這種工具,我可以使用一些消費模塊進行分發。 – 2017-04-27 20:40:29