Click here to Skip to main content
11,639,463 members (67,651 online)
Click here to Skip to main content

How to compile MFC code in Visual C++ Express

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

Introduction

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:

DemoMFC

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:

MFC_Express2.PNG

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:

MFC_Express3.PNG

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; }

into:

_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.

History

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

License

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

Share

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

 
GeneralRe: Visual Studio 2010 & Windows DDK Pin
kabouterjong10-Mar-14 5:53
memberkabouterjong10-Mar-14 5:53 
Generalrichedit.h missing Pin
D scruton22-Sep-10 4:51
memberD scruton22-Sep-10 4:51 
GeneralRe: richedit.h missing Pin
Danny Ruijters14-Apr-11 4:09
memberDanny Ruijters14-Apr-11 4:09 
GeneralRe: richedit.h missing Pin
D scruton14-Apr-11 7:12
memberD scruton14-Apr-11 7:12 
GeneralVisual C++ 2010 Express does include directory Pin
Serkan Turan5-Aug-10 1:42
memberSerkan Turan5-Aug-10 1:42 
GeneralRe: Visual C++ 2010 Express does include directory Pin
Danny Ruijters15-Aug-10 0:26
memberDanny Ruijters15-Aug-10 0:26 
Generalerror C2039: 'SetPoint' : is not a member of 'CPoint' 1 c:\winddk\3790.1830\inc\mfc42\afxwin.h(176) : see declaration of 'CPoint' Pin
comet006-Mar-10 7:33
membercomet006-Mar-10 7:33 
GeneralRe: error C2039: 'SetPoint' : is not a member of 'CPoint' 1 c:\winddk\3790.1830\inc\mfc42\afxwin.h(176) : see declaration of 'CPoint' Pin
Danny Ruijters9-Mar-10 1:03
memberDanny Ruijters9-Mar-10 1:03 
The SetPoint function is indeed not included in this version. Probably it was added later. The CPoint class can accessed e.g. as:
CPoint pnt;
pnt = CPoint(10,2);

I did not have any problems to access the Right(...) function of the CString class.

cheers,
Danny
QuestionI need help!! Error LNK2001:unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" [modified] Pin
xiaohang_9922-Jan-10 17:10
memberxiaohang_9922-Jan-10 17:10 
AnswerRe: I need help!! Error LNK2001:unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" Pin
Danny Ruijters22-Jan-10 21:09
memberDanny Ruijters22-Jan-10 21:09 
GeneralRe: I need help!! Error LNK2001:unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" Pin
xiaohang_9923-Jan-10 9:27
memberxiaohang_9923-Jan-10 9:27 
GeneralRe: I need help!! Error LNK2001:unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" Pin
PIntag12-Feb-10 9:24
memberPIntag12-Feb-10 9:24 
GeneralRe: I need help!! Error LNK2001:unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" Pin
Bob2H17-May-10 2:21
memberBob2H17-May-10 2:21 
GeneralRe: I need help!! Error LNK2001:unresolved external symbol "void __stdcall AfxThrowInvalidArgException(void)" Pin
magusbr13-Feb-11 11:02
membermagusbr13-Feb-11 11:02 
QuestionMigrate Projects from VC++ 6 to VC++ 2008 Express Pin
RonHartleb29-Jul-09 21:19
memberRonHartleb29-Jul-09 21:19 
AnswerRe: Migrate Projects from VC++ 6 to VC++ 2008 Express Pin
Danny Ruijters29-Jul-09 21:35
memberDanny Ruijters29-Jul-09 21:35 
GeneralRe: Migrate Projects from VC++ 6 to VC++ 2008 Express Pin
RonHartleb29-Jul-09 21:45
memberRonHartleb29-Jul-09 21:45 
GeneralRe: Migrate Projects from VC++ 6 to VC++ 2008 Express Pin
Danny Ruijters29-Jul-09 21:48
memberDanny Ruijters29-Jul-09 21:48 
Generalmfc42d.dll is missing Pin
dannyge27-Jul-09 12:40
memberdannyge27-Jul-09 12:40 
GeneralRe: mfc42d.dll is missing Pin
Danny Ruijters27-Jul-09 22:16
memberDanny Ruijters27-Jul-09 22:16 
GeneralRe: mfc42d.dll is missing Pin
dannyge28-Jul-09 11:24
memberdannyge28-Jul-09 11:24 
GeneralRe: mfc42d.dll is missing Pin
KarstenK29-Jul-09 21:24
memberKarstenK29-Jul-09 21:24 
GeneralStatically Link MFC Pin
thecodedemon29-Jun-09 6:10
memberthecodedemon29-Jun-09 6:10 
QuestionCan old MFC code and new CLR code work together? Pin
James King12-Jun-09 13:20
memberJames King12-Jun-09 13:20 
AnswerRe: Can old MFC code and new CLR code work together? Pin
Danny Ruijters12-Jun-09 23:11
memberDanny Ruijters12-Jun-09 23:11 

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 | Terms of Use | Mobile
Web02 | 2.8.150728.1 | Last Updated 26 Oct 2008
Article Copyright 2008 by Danny Ruijters
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid