如何判断一个lib是用/ mt还是/ md编译的? [英] How to tell if a lib was compiled with /mt or /md?

查看:2370
本文介绍了如何判断一个lib是用/ mt还是/ md编译的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个编译的 lib ,是否有一种方法来判断是否编译了 / md / mt 只需查看它(可能使用 dumpbin 工具)?

Given a compiled lib, is there a way to tell if it was compiled with /md or /mt just by looking at it (maybe with dumpbin tool)?

修改
dumpbin / directives foo.lib lib 未使用 / GL 开关编译。是否有一个选项来检查以这种方式优化的 lib 文件?

dumpbin /directives foo.lib is a solution for the case where the lib was not compiled with /GL switch. Is there an option to inspect a lib file that was optimized in such a way?

推荐答案

Microsoft编译器的一个非常好的功能是它保留用于将源文件编译为.obj文件的命令行。它允许你通过查看.lib文件,等待它,Notepad.exe找到它。只需搜索cl.exe。

A very nice feature of the Microsoft compiler is that it preserves the command line that was used to compile a source file into the .obj file. Which allows you to find it back by looking at the .lib file with, wait for it, Notepad.exe. Just search for "cl.exe".

例如,这是我在使用记事本打开一个名为Win32Project1.lib的示例库,我用VS2013 :

For example, this is what I see when I use Notepad opened on a sample library named Win32Project1.lib that I built with VS2013:


C:\Program Files(x86)\ Microsoft Visual Studio 12.0 \VC\bin\CL.exe cmd -c -ZI -nologo -W3 -WX- -sdl -Od -Oy- -DWIN32 -D_DEBUG -D_LIB -DHELLO_STACKOVERFLOW -D_UNICODE -DUNICODE -Gm -EHs -EHc -RTC1 -MDd -GS -fp:precise -Zc:wchar_t -Zc:forScope -Ycstdafx.h -Fpc:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\Win32Project1.pch-Foc:\Users \hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\-Fdc:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\ Debug \vc120.pdb-Gd -TP -analyze- -errorreport:prompt -IC:\Program Files(x86)\ Microsoft Visual Studio 12.0 \VC\include-IC:\程序文件(x86)\Microsoft Visual Studio 12.0 \VC\atlmfc\include-IC:\Program文件(x86)\Windows Kits\8.1 \Include\um-I C:\程序文件(x86)\Windows Kits \8.1 \Include \winrt - \\ X src stdafx.cpp pdb c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\vc120.pdb

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\CL.exe cmd -c -ZI -nologo -W3 -WX- -sdl -Od -Oy- -DWIN32 -D_DEBUG -D_LIB -DHELLO_STACKOVERFLOW -D_UNICODE -DUNICODE -Gm -EHs -EHc -RTC1 -MDd -GS -fp:precise -Zc:wchar_t -Zc:forScope -Ycstdafx.h -Fp"c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\Win32Project1.pch" -Fo"c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\" -Fd"c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\vc120.pdb" -Gd -TP -analyze- -errorreport:prompt -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include" -I"C:\Program Files (x86)\Windows Kits\8.1\Include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\Include\shared" -I"C:\Program Files (x86)\Windows Kits\8.1\Include\winrt" -X src stdafx.cpp pdb c:\Users\hpass_000\documents\visual studio 2013\Projects\Win32Project1\Debug\vc120.pdb

如你所知,我使用/ MDd编译

As you can tell, I compiled with /MDd

请注意.lib可能包含多个.obj文件, 。搜索-mt和-md可让您快速找到。

Do beware that a .lib can contain multiple .obj files with possibly different settings. Searching for "-mt" and "-md" lets you find out quickly.

这篇关于如何判断一个lib是用/ mt还是/ md编译的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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