I've spent most of my day trying to figure out why this error is occurring but it continues to mystify me.
I created a console application in Visual C++ and specified it to be empty. After putting all of my source in the virtual folder and compiling it an error occurred:
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal 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]
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal 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]
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afx.h(24): fatal 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]
Strange error indeed, because I never included any MFC files. So I remedied the situation by specifying "/MT" in the code generation settings.
This worked well...until I decided to include "Windows.h", which spawned this error:
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include windows.h
c:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxv_w32.h(16): fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include windows.h
I've tried everything I could think of, including recreating the project with and without precompiled headers, a Win32 app rather than console, and a WxWidget app. All of these apps seemingly try to include MFC even though I never specified. Can anyone shed some light on this problem? Thank you!
Find out what's including the MFC headers - the /showIncludes
option may help with that.
Which in the IDE project property page is under:
C/C++ | Advanced | Show Includes
Once you know who is including them you can make a decision on how to address the problem - you might simply be able to remove an errant #include
, but it might require jettisoning a library you're using that's dependent on MFC.
Make sure 'USE of MFC' is in 'Use MFC in a Shared DLL' setting. That fixed it for me.
If MFC is required, set the following values ( Debug/Win32 ):
Configuration Properties > General :
Use of MFC : Use MFC in a Shared DLL
Configuration Properties > C/C++ > Code Generation :
Runtime Library : /MDd
If MFC is not required, and only standard window libraries are required, keep the setting as below.
Configuration Properties > General :
Use of MFC : Use Standard Windows Libraries
Configuration Properties > C/C++ > Code Generation :
Runtime Library : /MTd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With