Click here to Skip to main content
Click here to Skip to main content

How to compile MFC code in Visual C++ Express

By , 25 Oct 2008
Rate this:
Please Sign up or sign in to vote.


The Microsoft Visual C++ Express edition can be downloaded free of charge. While the Express edition of Visual C++ offers a rich development environment, it lacks the possibilities to develop and compile MFC programs. In this article, I will explain how you still can compile MFC code within Visual C++ Express, which is particularly useful when you have a lot of old MFC code lying around, like I have.

Five simple steps

To compile MFC code within the Express edition of Visual C++, you first need to perform five steps:

Step 1 - First of all, you need to download and install the Visual C++ Express edition, if you have not already done so.

Step 2 - Go to the Windows Server 2003 driver development kit (DDK) webpage, download the DDK ISO file, and burn it to a CD. Most of the time, you can just use the CD burning software that comes with your computer for this task, or alternatively, you can use this software, or this.

Step 3 - Install the DDK from the CD (execute setup.exe on the CD). It is enough to simply install the default selection (Build Environment, Documentation, Tools for Driver Developers).

Step 4 - You have to add a couple of directory paths to tell Visual C++ where the MFC related files can be found. This can be done by selecting in the "Options..." entry in the "Tools" menu, like shown in the image below:


Then, in the "Projects and Solutions" entry in the list on the left, select "VC++ Directories". Now, in the "Show directories for" dropdown on the right, select "Include files". Here, you should add (simply click on an empty line) the following paths:

  • $(DDK_directory)\inc\mfc42
  • $(DDK_directory)\inc\atl30

whereby you should replace $(DDK_directory) with the directory where you installed the DDK in the previous step, which is "C:\WINDDK\3790.1830" in my case; see the image below:


Now, change the "Show directories for" dropdown to "Library files", and add:

  • $(DDK_directory)\lib\mfc\i386
  • $(DDK_directory)\lib\atl\i386

Again, replace $(DDK_directory) with the path to the DDK on your machine; see the image below:


Step 5 - In the last step, you have to edit the file "afxwin.inl", which can be found in the $(DDK_directory)\inc\mfc42 directory.

In this file, from line 1033 onwards, change:

_AFXWIN_INLINE CMenu::operator==(const CMenu& menu) const
    { return ((HMENU) menu) == m_hMenu; }
_AFXWIN_INLINE CMenu::operator!=(const CMenu& menu) const
    { return ((HMENU) menu) != m_hMenu; }


_AFXWIN_INLINE BOOL CMenu::operator==(const CMenu& menu) const
    { return ((HMENU) menu) == m_hMenu; }
_AFXWIN_INLINE BOOL CMenu::operator!=(const CMenu& menu) const
    { return ((HMENU) menu) != m_hMenu; }

Looking for the differences? Well, "BOOL" has been inserted twice (mind the capitals).

On your marks, Get set, Go!

Now, you are all set to compile MFC programs in the Visual C++ Express edition. Download the example program at the top of this article, and try it!

Aren't there any issues? Of course, there are! You just installed version 4.2 of MFC, which is the version that was delivered with Visual Studio 6. This means that if you have code that uses MFC features introduced after VS6, it will not compile. Further, you will not be able to run with the MFC debug DLLs, nor will you be able to link statically against MFC. Using dynamic linking in release mode makes everything run fine, though. Finally, the Express edition does not come with the drag and drop MFC resource editor. You can either edit your resource files (these are the files that determine how your windows look like) by hand in text mode, or you can try an external program.


  • October 26, 2008 - Initial version of the article.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Danny Ruijters
Software Developer (Senior)
Netherlands Netherlands
As a 3D Imaging Scientist, I build clinical prototype software, mainly in the domain of 3D cardio-vascular x-ray. The value of the prototypes is evaluated in hospitals by physicians, who use them in cardio-vascular interventions. Further it is my task to stay in touch with the scientific developments in 3D medical imaging.
I have been writing software for about 20 years now. The past 6 years I concerned myself mainly with 3D medical image processing, visualization and GPU programming.

Comments and Discussions

QuestionAny chance you could update for VS 2010 Express? PinmemberDavid Goldsmith13-Mar-14 9:18 
QuestionFrankie PingroupFranksLIC28-Jan-14 12:15 
QuestionThank you !!! Pinmembercncengraver23-Jan-13 4:16 
QuestionStatus_Dll_Not_Found PinmemberFrank Muir24-Nov-12 14:23 
AnswerRe: Status_Dll_Not_Found PinmemberDanny Ruijters24-Nov-12 22:16 
GeneralRe: Status_Dll_Not_Found PinmemberFrank Muir25-Nov-12 5:40 
QuestionAnd what about the license? Pinmembervaldok19-Feb-12 3:54 
AnswerRe: And what about the license? PinmemberMember 83901223-Feb-12 23:42 
AnswerRe: And what about the license? PinmemberMember 83901223-Feb-12 23:47 
GeneralIn step5, there are afxwin1.inl and afxwin2.inl.What should i do? which one to change or change all of them? Pinmemberx18576669411-May-11 15:42 
Generalcannot open file 'uafxcwd.lib' PinmemberMember 771337628-Feb-11 8:52 
GeneralRe: cannot open file 'uafxcwd.lib' PinmemberDanny Ruijters14-Apr-11 4:07 
GeneralVisual Studio 2010 & Windows DDK PinmemberDanny Ruijters28-Jan-11 17:20 
GeneralRe: Visual Studio 2010 & Windows DDK Pinmembervelociphile21-Nov-11 16:38 
Brilliant info above, thanks to all contributors.
On Cesare Brizio's info: the old project I'm trying to compile was giving lots of complaints of:
...missing identifier: AFX_CRT_ERRORCHECK
(from memory)
#if defined(USE_MFC6_WITH_ATL7)
#include "..\atlmfc\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
#include "..\atl30\atlconv.h"
#if defined(USE_MFC6_WITH_ATL7)
#include "..\atlmfc\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
#include "..\atl71\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
seems to have done the trick.
I hope this helps someone.
GeneralRe: Visual Studio 2010 & Windows DDK PinmemberAlessio Nava28-Jun-12 6:27 
GeneralRe: Visual Studio 2010 & Windows DDK PinmemberDanny Ruijters11-Oct-12 22:54 
GeneralRe: Visual Studio 2010 & Windows DDK Pinmembergggeek29-Aug-12 22:31 
GeneralRe: Visual Studio 2010 & Windows DDK Pinmembergggeek29-Aug-12 22:39 
GeneralRe: Visual Studio 2010 & Windows DDK PinmemberDanny Ruijters30-Jul-13 4:02 
GeneralRe: Visual Studio 2010 & Windows DDK PinmemberBoleczek11-Sep-12 8:30 
GeneralRe: Visual Studio 2010 & Windows DDK Pinmemberkabouterjong10-Mar-14 5:53 
Generalrichedit.h missing PinmemberD scruton22-Sep-10 4:51 
GeneralRe: richedit.h missing PinmemberDanny Ruijters14-Apr-11 4:09 
GeneralRe: richedit.h missing PinmemberD scruton14-Apr-11 7:12 
GeneralVisual C++ 2010 Express does include directory PinmemberSerkan Turan5-Aug-10 1:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 26 Oct 2008
Article Copyright 2008 by Danny Ruijters
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid