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
or /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,则通常可以使用它根据源文件信息和模块中存在的函数来确定链接的内容。
(两个注释:[1] 我的 test.cpp 文件是一个简单的 C Hello, World! 程序。如果它动态链接其他 Visual C++ 库,dumpbin /dependents
也会举报他们。 [2]dumpbin /dependents
与 DLL 的配合也同样良好。)