Author Topic: Compile FRED with MS Visual C++ Studio Express 2010  (Read 12784 times)

0 Members and 1 Guest are viewing this topic.

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Compile FRED with MS Visual C++ Studio Express 2010
Alright, I'm trying to see if I can get this working... this may be already known, it may not work, or maybe it will end up helping some people, we'll see!  (Ya, I know, I'm crazy. Moving on..)

Get VC++ Express 2010

Get Windows Driver Kit 7.10, currently found at http://www.microsoft.com/en-us/download/details.aspx?id=11800

Mount the ISO, run KitSetup.exe, install only (unless you want the other components for reasons of your own):

  • Build Environments
  • Tools
  • Help (Documentation Collection)


Taken from: http://www.codeproject.com/Articles/30439/How-to-compile-MFC-code-in-Visual-C-Express

Quote
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 (Should be already done, above, the new link is: WDK 7.10, here), download the DDK ISO file, and burn mount it to a the CD image. 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(Or just use Slysoft Virtual CloneDrive or Daemon Tools Lite to mount the .iso and use that route... like we just did... right?) ;)

Step 3 - Install the DDK from the CD (execute setup.exe on the CD). already done above 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:
  • 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
  • The custom additional folders to be added to the project should include also the LIB directories from DDK
  • 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.



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 $(DDK_directory)\inc\atl71

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 (BREAK...)


NOTE: It appears the last step, step 5, is no longer needed, see Point 5 of the first additional quote after this one - Points 2 through 4 of that quote have been addressed above, however, as mentioned in the second additional quote below,


Code: [Select]
c:\winddk\7600.16385.1\inc\mfc42\atlconv.h
needs to be changed from

Code: [Select]
#if defined(USE_MFC6_WITH_ATL7)
#include "..\atlmfc\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
AtlCrtErrorCheck(expr)
       
#else
#include "..\atl30\atlconv.h"
#define _ATL_NO_CONVERSIONS
#endif

to

Code: [Select]
#if defined(USE_MFC6_WITH_ATL7)
#include "..\atlmfc\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
AtlCrtErrorCheck(expr)
       
#else
#include "..\atl71\atlconv.h"
//#define _ATL_NO_CONVERSIONS
#define AFX_CRT_ERRORCHECK(expr) \
AtlCrtErrorCheck(expr)
#endif

(continued...), you have to edit the file "afxwin.inl", which can be found in the $(DDK_directory)\inc\mfc42 directory.

NOT NEEDED ANY MORE:
In this file, from line 1033 onwards, change:

Code: [Select]
_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:

Code: [Select]
_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)

About the Author

Danny Ruijters

Software Developer (Senior) - 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.



http://www.codeproject.com/Messages/3751997/Visual-Studio-2010-Windows-DDK.aspx
Quote
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 (“http://www.codeproject.com/KB/MFC/MFCinVisualStudioExpress.aspx”).
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: http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff – 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


http://www.codeproject.com/Messages/4084245/Re-Visual-Studio-2010-Windows-DDK.aspx
Quote
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:

Code: [Select]
...missing identifier: AFX_CRT_ERRORCHECK
(from memory)
 
Editing

Code: [Select]
c:\winddk\7600.16385.1\inc\mfc42\atlconv.h
from:
 
Code: [Select]
#if defined(USE_MFC6_WITH_ATL7)
#include "..\atlmfc\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
AtlCrtErrorCheck(expr)
       
#else
#include "..\atl30\atlconv.h"
#define _ATL_NO_CONVERSIONS
#endif

to:

Code: [Select]
#if defined(USE_MFC6_WITH_ATL7)
#include "..\atlmfc\atlconv.h"
#define AFX_CRT_ERRORCHECK(expr) \
AtlCrtErrorCheck(expr)
       
#else
#include "..\atl71\atlconv.h"
//#define _ATL_NO_CONVERSIONS
#define AFX_CRT_ERRORCHECK(expr) \
AtlCrtErrorCheck(expr)
#endif

seems to have done the trick.
 
I hope this helps someone.
« Last Edit: May 01, 2012, 12:27:07 am by jr2 »

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: Compile FRED with MS Visual C++ Studio Express 2010
Sorry for my in-progress editing... I thought I had it the way I wanted it, then I re-read it, and ask myself if I am trying to drive any rational person who would be reading it into insanity.  :rolleyes:  My apologies.

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: Compile FRED with MS Visual C++ Studio Express 2010
Alright, to attempt FRED compilation, do I need to change Configuration Properties > Debugging > Command to
Code: [Select]
$(FS2PATH)\$(TargetFileName)
?

EDIT: I do need this answered... I changed it based on my gut feeling, but I have as much chance of being right as I do guessing a coin flip.
« Last Edit: May 01, 2012, 12:30:17 am by jr2 »

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: Compile FRED with MS Visual C++ Studio Express 2010
OK, made a user environment variable for DDK_directory (in my case, C:\WinDDK\7600.16385.1 ) - this way, I can just use $(DDK_directory)\lib\mfc\i386, $(DDK_directory)\lib\atl\i386, (library files) and $(DDK_directory)\inc\mfc42, $(DDK_directory)\inc\atl30 (include files)

Wait... atl30 should be atl71.. gotta change that

EDIT: "The custom additional folder should include the LIB directories from DDK" Great.  I assume, the library files part, because of the directory name LIB... but just $(DDK_directory)\lib ?? I'm doing that, we'll see (I don't think this is right... it doesn't feel right. nothing in there but a bunch of folders... did he mean every directory in LIB or what??)

EDIT2: Nope, not doing it, $(DDK_directory)\lib isn't going in here, there's not enough information, and I'm positive it's not just \lib ... I'm also pretty darn sure it's not every directory under \lib either as many of them seem related specifically to Windows drivers.
« Last Edit: May 01, 2012, 12:44:47 am by jr2 »

 

Offline jr2

  • The Mail Man
  • 212
  • It's prounounced jayartoo 0x6A7232
    • Steam
Re: Compile FRED with MS Visual C++ Studio Express 2010
These lines have issues:

7>c:\games\freespace 2\fs2_open\code\fred2\initialstatus.cpp(818): warning C4245: 'argument' : conversion from 'int' to 'DWORD_PTR', signed/unsigned mismatch

7>c:\games\freespace 2\fs2_open\code\fred2\campaigntreewnd.cpp(228): warning C4239: nonstandard extension used : 'argument' : conversion from 'CString' to 'CString &'
7>          A non-const reference may only be bound to an lvalue

7>c:\games\freespace 2\fs2_open\code\fred2\asteroideditordlg.cpp(443): warning C4245: 'argument' : conversion from 'int' to 'DWORD_PTR', signed/unsigned mismatch

7>  Generating Code...
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(152): error RC2135: file not found: res\help.cur
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(171): error RC2135: file not found: res\3dcheck.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(194): error RC2135: file not found: res\minifwnd.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(199): error RC2135: file not found: res\ntcheck.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(200): error RC2135: file not found: res\95check.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxprint.rc(31): error RC2135: file not found: res\magnify.cur
7> 
========== Build: 6 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



So... ideas?

Feel free to tell me it's never going to work, but, if you could do me a favor and tell me why, I'd feel better.  :nod:

To me it just looks like a few errors and some missing resources.

Code: [Select]
1>------ Build started: Project: liblua, Configuration: Debug Inferno SSE2 Win32 ------
2>------ Build started: Project: zlib, Configuration: Debug Inferno SSE2 Win32 ------
3>------ Build started: Project: libpng, Configuration: Debug Inferno SSE2 Win32 ------
4>------ Build started: Project: libjpeg, Configuration: Debug Inferno SSE2 Win32 ------
2>  zlib.vcxproj -> C:\Games\Freespace 2\fs2_open\projects\MSVC_2010\Debug Inferno SSE2\zlib.lib
3>  libpng.vcxproj -> C:\Games\Freespace 2\fs2_open\projects\MSVC_2010\Debug Inferno SSE2\libpng.lib
4>  libjpeg.vcxproj -> C:\Games\Freespace 2\fs2_open\projects\MSVC_2010\Debug Inferno SSE2\libjpeg.lib
1>  liblua.vcxproj -> C:\Games\Freespace 2\fs2_open\projects\MSVC_2010\Debug Inferno SSE2\liblua.lib
5>------ Build started: Project: code, Configuration: Debug Inferno SSE2 Win32 ------
5>  code.vcxproj -> C:\Games\Freespace 2\fs2_open\projects\MSVC_2010\Debug Inferno SSE2\code.lib
6>------ Build started: Project: Freespace2, Configuration: Debug Inferno SSE2 Win32 ------
7>------ Build started: Project: Fred2, Configuration: Debug Inferno SSE2 Win32 ------
7>  wing_editor.cpp
7>  wing.cpp
7>  weaponeditordlg.cpp
6>  Freespace2.vcxproj -> C:\Games\Freespace 2\fs2_open\projects\MSVC_2010\Debug Inferno SSE2\fs2_open_3_6_13d_INF_SSE2.exe
6>          1 file(s) copied.
6>          1 file(s) copied.
7>  waypointpathdlg.cpp
7>  voiceactingmanager.cpp
7>  textviewdlg.cpp
7>  stdafx.cpp
7>  starfieldeditor.cpp
7>  soundenvironmentdlg.cpp
7>  shiptexturesdlg.cpp
7>  shipspecialhitpoints.cpp
7>  shipspecialdamage.cpp
7>  shipgoalsdlg.cpp
7>  shipflagsdlg.cpp
7>  shipeditordlg.cpp
7>  shipclasseditordlg.cpp
7>  shipchecklistbox.cpp
7>  ship_select.cpp
7>  shieldsysdlg.cpp
7>  sexp_tree.cpp
7>  Generating Code...
7>  Compiling...
7>  setglobalshipflags.cpp
7>  restrictpaths.cpp
7>  reinforcementeditordlg.cpp
7>  prefsdlg.cpp
7>  playerstarteditor.cpp
7>  orienteditor.cpp
7>  operatorargtypeselect.cpp
7>  modifyvariabledlg.cpp
7>  missionsave.cpp
7>  missionnotesdlg.cpp
7>  missiongoalsdlg.cpp
7>  messageeditordlg.cpp
7>  management.cpp
7>  mainfrm.cpp
7>  initialstatus.cpp
7>c:\games\freespace 2\fs2_open\code\fred2\initialstatus.cpp(818): warning C4245: 'argument' : conversion from 'int' to 'DWORD_PTR', signed/unsigned mismatch
7>  initialships.cpp
7>  ignoreordersdlg.cpp
7>  grid.cpp
7>  fredview.cpp
7>  fredrender.cpp
7>  Generating Code...
7>  Compiling...
7>  freddoc.cpp
7>  fred.cpp
7>  folderdlg.cpp
7>  eventeditor.cpp
7>  dumpstats.cpp
7>  dialog1.cpp
7>  debriefingeditordlg.cpp
7>  customwingnames.cpp
7>  createwingdlg.cpp
7>  cmdbrief.cpp
7>  campaigntreewnd.cpp
7>c:\games\freespace 2\fs2_open\code\fred2\campaigntreewnd.cpp(228): warning C4239: nonstandard extension used : 'argument' : conversion from 'CString' to 'CString &'
7>          A non-const reference may only be bound to an lvalue
7>  campaigntreeview.cpp
7>  campaignfilelistbox.cpp
7>  campaigneditordlg.cpp
7>  briefingeditordlg.cpp
7>  bgbitmapdlg.cpp
7>  backgroundchooser.cpp
7>  asteroideditordlg.cpp
7>c:\games\freespace 2\fs2_open\code\fred2\asteroideditordlg.cpp(443): warning C4245: 'argument' : conversion from 'int' to 'DWORD_PTR', signed/unsigned mismatch
7>  adjustgriddlg.cpp
7>  addvariabledlg.cpp
7>  Generating Code...
7>  Compiling...
7>  FictionViewerDlg.cpp
7>  AltShipClassDlg.cpp
7>  Generating Code...
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(152): error RC2135: file not found: res\help.cur
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(171): error RC2135: file not found: res\3dcheck.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(194): error RC2135: file not found: res\minifwnd.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(199): error RC2135: file not found: res\ntcheck.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxres.rc(200): error RC2135: file not found: res\95check.bmp
7> 
7> 
7>C:\WinDDK\7600.16385.1\inc\mfc42\afxprint.rc(31): error RC2135: file not found: res\magnify.cur
7> 
========== Build: 6 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

[attachment deleted by a ninja]

 

Offline Iss Mneur

  • 210
  • TODO:
Re: Compile FRED with MS Visual C++ Studio Express 2010
Alright, to attempt FRED compilation, do I need to change Configuration Properties > Debugging > Command to
Code: [Select]
$(FS2PATH)\$(TargetFileName)
?

EDIT: I do need this answered... I changed it based on my gut feeling, but I have as much chance of being right as I do guessing a coin flip.
If you want to be able to F5 debug FRED (or rightclick and start debugging if FRED isn't your default project) then yes you need to set that for all compile profiles.

So... ideas?

Feel free to tell me it's never going to work, but, if you could do me a favor and tell me why, I'd feel better.  :nod:

To me it just looks like a few errors and some missing resources.
The warnings are probably non fatal.  I am pretty sure that I see them when I build FRED with my non express copy of VS2010.

As for the missing resources, it looks like you are compiling the wrong .rc file. That is, you are compiling a driver installer .rc and not FRED.rc.  Otherwise, I have no idea, it just works for me :|
"I love deadlines. I like the whooshing sound they make as they fly by." -Douglas Adams
wxLauncher 0.9.4 public beta (now with no config file editing for FRED) | wxLauncher 2.0 Request for Comments

  

Offline Tomo

  • 28
Re: Compile FRED with MS Visual C++ Studio Express 2010
Pretty sure the missing resources are supposed to be part of MFC/ATL

The "*check.bmp" ones are the graphics used for NT and Win95 checkboxes (possibly Win98 as well), I suspect the others are similar.

Have a look and see if you can find them, perhaps they are in the wrong place in your copy of MFC - I wouldn't be surprised if they are completely missing from ATL71 as they are probably rather ancient resources.

This MSDN post appears to be relevant, though annoyingly there isn't a real solution given.