4.3. Compiling the MFC

Here is a set of recommendations for getting the MFC compiled with WineLib:

We recommend running winemaker in '--interactive' mode to specify the right options for the MFC and the ATL part (to get the include paths right, to not consider the MFC MFC-based, and to get it to build libraries, not executables).

Then when compiling it you will indeed need a number of _AFX_NO_XXX macros. But this is not enough and there are other things you will need to '#ifdef-out'. For instance Wine's richedit support is not very good. Here are the AFX options I use:

#define _AFX_PORTABLE
#define _FORCENAMELESSUNION
#define _AFX_NO_DAO_SUPPORT
#define _AFX_NO_DHTML_SUPPORT
#define _AFX_NO_OLEDB_SUPPORT
#define _AFX_NO_RICHEDIT_SUPPORT
        

You will also need custom ones for CMonikerFile, OleDB, HtmlView, ...

We recommend using Wine's msvcrt headers (-isystem $(WINE_INCLUDE_ROOT)/msvcrt), though it means you will have to temporarily disable winsock support (#ifdef it out in windows.h).

You should use g++ compiler more recent than g++ 2.95. g++ 2.95 does not support unnamed structs while the more recent ones do, and this helps a lot. Here are the options worth mentioning:

When you first reach the link stage you will get a lot of undefined symbol errors. To fix these you will need to go back to the source and #ifdef-out more code until you reach a 'closure'. There are also some files that don't need to be compiled.

Maybe we will have ready-made makefile here someday...