简体   繁体   English

Win32项目生成MFC错误

[英]Win32 Project Generating MFC error

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. 错误C1189:#error:使用/ MD建立MFC应用程序[d](CRT dll版本)需要MFC共享dll版本。 Please #define _AFXDLL or do not use /MD[d] 请#define _AFXDLL或不要使用/ MD [d]

IntelliSense: #error directive: WINDOWS.H already included. IntelliSense:#error指令:已包含WINDOWS.H。 MFC apps must not #include MFC应用程序不得#include

My Question is why WIN32 project is generating MFC error, and how should i remove this error, kindly guide me 我的问题是为什么WIN32项目正在生成MFC错误,我应该如何删除此错误,请指导我

The problem is that one of the headers you're including is including 'afx.h'. 问题是你所包含的标题之一是'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. 标头做的第一件事是检查_DLL是否已定义,如果它存在则查找_AFXDLL并显示此错误消息(如果尚未定义)。 Here's the relevant bit from afx.h 这是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++ -> Advanced switch Show Includes ON to see where afx.h is being included. 如果您不想包含MFC,请转到您的项目属性并在C / C ++ - > Advanced开关Show Includes ON下查看包含 afx.h的位置。

Could you try this: 你能试一试吗:

Change 更改

Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library 项目属性 - >配置属性 - > C / C ++ - >代码生成 - >运行时库

As

Multi-threaded DLL (/MD) 多线程DLL(/ MD)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM