如何检查从 VC++ 生成的二进制 exe 的运行时库类型 [英] How to check the runtime library type of a binary exe generated from VC++

查看:25
本文介绍了如何检查从 VC++ 生成的二进制 exe 的运行时库类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于对现有构建(二进制文件、exe、dll、lib 集)进行故障排除.

For the purposes of troubleshooting an existing build (set of binary files, exe's, dll's, lib's).

有没有办法使用 SDK 或其他实用程序中的命令行工具来快速检查编译目标文件所针对的运行时库类型?

Is there a way, with command line tools from SDK or other utility to quickly check the Runtime Library Type an object file was compiled against?

例如,给定一个 .dll 很明显它是针对动态运行时编译的(但如果它是 Debug 或 Release 版本,它仍然不明显).

For example, given a .dll is obvious it was compiled against Dynamic runtime (but its still not obvious if it is the Debug or Release version).

虽然在 .exe 的情况下更难(确定是否使用了动态/静态和调试/发布).

While in the case of a .exe is more difficult (to determine eithr if Dynamic/Static and Debug/Release were used).

(我的意思是,无需打开 VC++ 项目文件或查看 nmake/msbuild 文件中使用的编译器选项).

(I mean, without having to open the VC++ project files or looking at the compiler options used in a nmake / msbuild file).

推荐答案

dumpbin/dependents 将允许您确定模块(EXE 或 DLL)是否依赖于 Visual C++ 库 DLL(以及哪些这些 DLL 的版本和风格——调试或发布).例如,使用 Visual C++ 2013...

dumpbin /dependents will allow you to determine whether a module (EXE or DLL) depends on the Visual C++ libraries DLLs (and which versions and flavors--debug or release--of those DLLs). For example, with Visual C++ 2013...

当您使用 /MD 编译时,您的模块依赖于零售 msvcr120.dll:

When you compile with /MD, your module depends on the retail msvcr120.dll:

>cl /MD /nologo test.cpp
test.cpp

>dumpbin /dependents test.exe | findstr dll
    MSVCR120.dll
    KERNEL32.dll

当你用 /MDd 编译时,你的模块依赖于调试 msvcr120d.dll:

When you compile with /MDd, your module depends on the debug msvcr120d.dll:

>cl /MDd /nologo test.cpp
test.cpp

>dumpbin /dependents test.exe | findstr dll
    MSVCR120D.dll
    KERNEL32.dll

当您使用 /MT/MTd 进行编译时,您的模块不依赖于任何 CRT DLL:

When you compile with /MT or /MTd, your module does not depend on any 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,您通常可以使用它来根据源文件信息和模块中存在的函数找出链接的内容.

When you've statically linked the Visual C++ libraries, it's generally not possible to tell whether the retail or debug libraries were linked in (in general you can't tell whether any Visual C++ libraries were linked in). If you have a PDB for your module, you can often use that to figure out what was linked in, based on source file information and functions present in the module.

(两个注意事项:[1] 我的 test.cpp 文件是一个简单的 C Hello, World! 程序.如果它动态链接其他 Visual C++ 库,dumpbin/dependents 也会报告它们.[2] dumpbin/dependents 对 DLL 也同样有效.)

(Two notes: [1] My test.cpp file was a simple C Hello, World! program. If it linked other Visual C++ libraries dynamically, dumpbin /dependents will also report them. [2] dumpbin /dependents works equally well with DLLs.)

这篇关于如何检查从 VC++ 生成的二进制 exe 的运行时库类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆