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 richedit support is not very good. Here are the AFX options I use:


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

We recommend using Wine 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 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:

  • -fms-extensions (helps get more code to compile)

  • -fshort-wchar -DWINE_UNICODE_NATIVE (helps with Unicode support)

  • -DICOM_USE_COM_INTERFACE_ATTRIBUTE (to get the COM code to work)

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