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