is there a tool in windows SDK to ckeck what CRT a library uses? for example I have a *.lib file, how do check if it's compiled with /MDd flag or /MT? also how to check the same for dll or exe? can this be done with dumpbin?
1 Answers
If it is a .lib file, a static link library, then you don't know anything about the CRT yet. It wasn't linked yet. You can find out about the original programmer's intention, use a hex viewer to look the .lib file, Notepad will do fine as well. You'll see the original command line that was used to compile the .obj files that were embedded in the .lib file. Simply search for "cl.exe", you'll have a good idea what compiler version was used from the path to cl.exe. And you can see the command line options so you'll know if /MD or /MT was in effect. And the /O option, important to have an idea whether you've got a Debug or Release build.
If it is a .dll file then dumpbin.exe /imports is your best choice. The dependency on the msvcrxxx.dll file will be visible, with xxx the version number like "120". If you see it then the name tells you if /MD or /MDd was used, "d" is appended for the Debug version of the CRT If it is missing then you know that /MT or /MTd was used, no hint about the build flavor available.
Following the recommendations from the library owner is always best, you can get into a lot of trouble when the CRT version or build settings of the library doesn't match yours. With non-zero odds that you have to ask him for an update, YMMV.

- 922,412
- 146
- 1,693
- 2,536
-
+1 for pointing out that the build options are as important as the specific CRT in use for a smooth ride. Since the OP specifically asked for dumpbin.exe, it's also worth noting, that all command line options (except for /HEADERS) are incompatible with the /GL compiler option. – IInspectable Aug 13 '14 at 12:35
-
Has the embedding of original command in the generated .lib stopped being the case with Visual studio 2015? – 0fnt Jun 04 '16 at 10:26
-
No, that still works. It does however require the /GL option to be turned on (enable whole program optimization), a library vendor must never disable it. – Hans Passant Jun 04 '16 at 10:49
-
2In all the .lib files I'm inspecting, I only see -defaultlib:MSVCRT or -defaultlib:MSVCRTD rather than the entire cl.exe dcommand-line. But the defautlib flag is enough to tell whether /MD or /MDD got passed to cl.exe. – buzz3791 Oct 06 '16 at 15:39