C++ #error 请使用 /MD 开关进行 _AFXDLL 构建

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4229120/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 14:53:04  来源:igfitidea点击:

#error Please use the /MD switch for _AFXDLL builds

c++visual-c++build

提问by Alex.Yang

I encountered an error in Visual Studio, Please use the /MD switch for _AFXDLL buildsso if I undefine the _AFXDLL, will my program go wrong?

我在 Visual Studio 中遇到错误,Please use the /MD switch for _AFXDLL builds所以如果我取消定义_AFXDLL,我的程序会出错吗?

回答by banuj

Settings for CRT linking and MFC linking must be coherent. So, actually, there are two possible answers at this question:

CRT 链接和 MFC 链接的设置必须一致。所以,实际上,这个问题有两个可能的答案:

  1. Use /MT (Properties -> C/C++ -> Code Generation) and static MFC (Properties -> General -> Use of MFC)

  2. Use /MD (Properties -> C/C++ -> Code Generation) and shared MFC (Properties -> General -> Use of MFC)

  1. 使用 /MT(属性 -> C/C++ -> 代码生成)和静态 MFC(属性 -> 通用 -> MFC 的使用)

  2. 使用 /MD(属性 -> C/C++ -> 代码生成)和共享 MFC(属性 -> 通用 -> MFC 的使用)

回答by Ben

Yes it will. What you should do is is go to your Visual Studio project properties. In Configuration Properties -> C/C++ -> Code Generation make sure you are using the Multi-threaded Dll for your Runtime Library.

是的,它会。您应该做的是转到您的 Visual Studio 项目属性。在配置属性 -> C/C++ -> 代码生成中,确保为运行时库使用多线程 Dll。

That will solve your problems.

那将解决您的问题。