在 Visual Studio 中,有编译标志/MD 和/MT,可让您选择所需的 C 运行时库类型.
In Visual Studio, there's the compile flags /MD and /MT which let you choose which kind of C runtime library you want.
我了解实现上的差异,但我仍然不确定该使用哪一个.有什么优点/缺点?
I understand the difference in implementation, but I'm still not sure which one to use. What are the pros/cons?
我听说/MD 的一个优点是它允许某人更新运行时(例如可能修补安全问题)并且我的应用程序将从此更新中受益.尽管对我来说,这几乎像是一个非功能:我不希望人们在不让我针对新版本进行测试的情况下更改我的运行时!
One advantage to /MD that I've heard, is that this allows someone to update the runtime, (like maybe patch a security problem) and my app will benefit from this update. Although to me, this almost seems like a non-feature: I don't want people changing my runtime without allowing me to test against the new version!
一些我很好奇的事情:
通过与/MD 动态链接,
By dynamically linking with /MD,
我还发现,在实践中,当使用使用不同运行时选项构建的静态链接的第 3 方仅二进制库时,主应用程序中的/MT 往往比/MD 更容易引起冲突(因为如果 C 运行时被多次静态链接,你会遇到麻烦,尤其是当它们是不同的版本时).
I've also found that in practice, when working with statically-linked 3rd-party binary-only libraries that have been built with different runtime options, /MT in the main application tends to cause conflicts much more often than /MD (because you'll run into trouble if the C runtime is statically-linked multiple times, especially if they are different versions).
这篇关于我应该用/MD 还是/MT 编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!