我应该用/ MD还是/ MT编译? [英] Should I compile with /MD or /MT?

查看:124
本文介绍了我应该用/ MD还是/ MT编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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,


  • 您暴露于系统更新(好或坏),

  • 您的可执行文件可以更小(因为它没有嵌入库)和

  • 我相信至少DLL的代码段在所有正在使用它的进程之间共享(减少所消耗的RAM总量)。

我还发现,在实践中,当使用静态链接的第三方二进制库使用不同的运行时选项构建时,/ 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编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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