Click here to Skip to main content
12,829,374 members (40,520 online)
Click here to Skip to main content
Add your own
alternative version


103 bookmarked
Posted 25 Oct 2008

How to compile MFC code in Visual C++ Express

, 25 Oct 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
How to compile your existing MFC code in Visual C++ Express.


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.

You may also be interested in...

Comments and Discussions

Questionthe simple way to do this. Pin
Member 1020061227-Aug-15 18:35
memberMember 1020061227-Aug-15 18:35 
QuestionIs VS 2013 Express a lost cause? Pin
Robert Webb28-Oct-14 2:49
memberRobert Webb28-Oct-14 2:49 
QuestionHow to compile MFC code in Visual C++ Express Pin
Member 1089953929-Jun-14 0:02
memberMember 1089953929-Jun-14 0:02 
AnswerRe: How to compile MFC code in Visual C++ Express Pin
Danny Ruijters29-Jun-14 23:48
memberDanny Ruijters29-Jun-14 23:48 
QuestionAny chance you could update for VS 2010 Express? Pin
David Goldsmith13-Mar-14 10:18
memberDavid Goldsmith13-Mar-14 10:18 
QuestionFrankie Pin
FranksLIC28-Jan-14 13:15
groupFranksLIC28-Jan-14 13:15 
QuestionThank you !!! Pin
cncengraver23-Jan-13 5:16
membercncengraver23-Jan-13 5:16 
QuestionStatus_Dll_Not_Found Pin
Frank Muir24-Nov-12 15:23
memberFrank Muir24-Nov-12 15:23 
AnswerRe: Status_Dll_Not_Found Pin
Danny Ruijters24-Nov-12 23:16
memberDanny Ruijters24-Nov-12 23:16 
GeneralRe: Status_Dll_Not_Found Pin
Frank Muir25-Nov-12 6:40
memberFrank Muir25-Nov-12 6:40 
QuestionAnd what about the license? Pin
valdok19-Feb-12 4:54
membervaldok19-Feb-12 4:54 
AnswerRe: And what about the license? Pin
Member 83901224-Feb-12 0:42
memberMember 83901224-Feb-12 0:42 
AnswerRe: And what about the license? Pin
Member 83901224-Feb-12 0:47
memberMember 83901224-Feb-12 0:47 
GeneralIn step5, there are afxwin1.inl and afxwin2.inl.What should i do? which one to change or change all of them? Pin
x18576669411-May-11 16:42
memberx18576669411-May-11 16:42 
Generalcannot open file 'uafxcwd.lib' Pin
Member 771337628-Feb-11 9:52
memberMember 771337628-Feb-11 9:52 
GeneralRe: cannot open file 'uafxcwd.lib' Pin
Danny Ruijters14-Apr-11 5:07
memberDanny Ruijters14-Apr-11 5:07 
GeneralVisual Studio 2010 & Windows DDK Pin
Danny Ruijters28-Jan-11 18:20
memberDanny Ruijters28-Jan-11 18:20 
As time passes, some things have changed (Visual Studio 2010 came along, and the Windows DDK has been updated). Luckily, Cesare Brizio has tried the approach of this article with these new developments, and emailed the results to me. I have copy-pasted that email below, so that you can reap the fruits of his work.

kind regards - Danny

Dear Danny:
I am 51 years old, Italian, and I have been an IT professional for more than 25 years.
As time passed, my technical engagements become less and less frequent, and since many years I became just the “communication and marketing” person of the businesses I collaborate with.
But still the interest for software development emerges from time to time, so I decided to give a try to Visual Studio Express 2010, and chose c++ (a language that I know just very little) just because there was source code available for developing bitmap convolution filters and sound spectrum analyzers – the two issues that I am interested into.
The burning disappointment of discovering that MFC and APL were not included (and acquiring a professional visual studio was out of question, for a simple curiosity like mine...) was soothened and then completely healed by your much welcome and exhaustive contribution (“”).
Now, thanks to you, I saved several hundred euros in a completely licit way, and I successfully compiled the two brilliant projects by Silviu Caragea (convolution filters) and Bartosz Milewsky (Frequency Analyzer).

The only slight differences that I found from your guidelines are the following:

1) The new address for downloading the Windows DDK is: – While MFC is still at version 42, ATL changed from “atl30” to “atl71”

2) In Visual Studio 2010, the additional folders for include and libraries are a property of the project configuration, not of the platform configuration, and must be input separately in each project for debug mode and for release mode

3) The custom additional folders to be added to the project should include also the LIB directories from DDK

4) After installing the new Windows DDK, one should go to the inc\mfc42 folder and locate atldef.h and atlconv.h and substitute references to the “atl30” folder with the “atl71” folder.

5) the “afxwin.inl” patch that you suggested seems to be not needed anymore.

Many thanks,
Cesare Brizio
GeneralRe: Visual Studio 2010 & Windows DDK Pin
velociphile21-Nov-11 17:38
membervelociphile21-Nov-11 17:38 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
Alessio Nava28-Jun-12 7:27
memberAlessio Nava28-Jun-12 7:27 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
Danny Ruijters11-Oct-12 23:54
memberDanny Ruijters11-Oct-12 23:54 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
gggeek29-Aug-12 23:31
membergggeek29-Aug-12 23:31 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
gggeek29-Aug-12 23:39
membergggeek29-Aug-12 23:39 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
Danny Ruijters30-Jul-13 5:02
memberDanny Ruijters30-Jul-13 5:02 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
Boleczek11-Sep-12 9:30
memberBoleczek11-Sep-12 9:30 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
kabouterjong10-Mar-14 6:53
memberkabouterjong10-Mar-14 6:53 

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

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

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