C++ Win32 项目生成 MFC 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18692338/
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-27 22:08:15  来源:igfitidea点击:

Win32 Project Generating MFC error

c++visual-studio-2010visual-studiovisual-c++mfc

提问by WiXXeY

I am working on a Win32 project in Visual Studio 2010. it is generating an MFC error, the error is given below

我正在 Visual Studio 2010 中处理 Win32 项目。它生成 MFC 错误,错误如下

error C1189: #error : Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

IntelliSense: #error directive: WINDOWS.H already included. MFC apps must not #include

错误 C1189:#error:使用 /MD[d](CRT dll 版本)构建 MFC 应用程序需要 MFC 共享 dll 版本。请#define _AFXDLL 或不要使用 /MD[d]

智能感知:#error 指令:WINDOWS.H 已包含在内。MFC 应用程序不得#include

My Question is why WIN32 project is generating MFC error, and how should i remove this error, kindly guide me

我的问题是为什么 WIN32 项目会产生 MFC 错误,我应该如何消除这个错误,请指导我

采纳答案by Cihan T.

Could you try this:

你可以试试这个:

Change

改变

Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library

项目属性 -> 配置属性 -> C/C++ -> 代码生成 -> 运行时库

As

作为

Multi-threaded DLL (/MD)

多线程DLL (/MD)

回答by snowdude

The problem is that one of the headers you're including is including 'afx.h'. The first thing that header does is check to see if _DLL as been defined and if that's present it looks for _AFXDLL and shows this error message if it's not been defined. Here's the relevant bit from afx.h

问题是您包含的标题之一包含“afx.h”。标头所做的第一件事是检查 _DLL 是否已定义,如果存在,它会查找 _AFXDLL 并在未定义时显示此错误消息。这是 afx.h 中的相关部分

#ifdef _DLL
#ifndef _AFXDLL
#error Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]
#endif
#endif

If you don't want to include MFC go to your project properties and under C/C++ -> Advancedswitch Show IncludesON to see where afx.h is being included.

如果您不想包含 MFC,请转到您的项目属性,然后在C/C++ -> Advanced开关Show IncludesON 下查看包含afx.h 的位置。