The MFC Library is available in versions that support ANSI single-byte and multibyte character set (MBCS) code, as well as versions that support Unicode (encoded as UTF-16LE, the Windows-native character set). Each MFC version is available as a static library or as a shared DLL. There is also a smaller MFC static library version that leaves out MFC controls for dialogs, for applications that are very sensitive to size and don't need those controls. The MFC libraries are available in both debug and release versions for supported architectures that include x86, x64, and ARM processors. You can create both applications (.exe files) and DLLs with any version of the MFC libraries. There is also a set of MFC libraries compiled for interfacing with managed code. The MFC shared DLLs include a version number to indicate library binary compatibility.
Automatic linking of MFC library versions
The MFC header files automatically determine the correct version of the MFC library to link, based on values defined in your build environment. The MFC header files add compiler directives instructing the linker to link in a specific version of the MFC library.
For example, the AFX.H header file instructs the linker to link in the full static, limited static, or shared DLL version of MFC; ANSI/MBCS or Unicode version; and debug or retail version, depending on your build configuration:
MFC header files also include directives to link in all required libraries, including MFC libraries, Win32 libraries, OLE libraries, OLE libraries built from samples, ODBC libraries, and so on.
ANSI, MBCS, and Unicode
The MFC ANSI/MBCS library versions support both single-byte character sets such as ASCII, and multibyte character sets such as Shift-JIS. The MFC Unicode library versions support Unicode in its UTF-16LE wide-character encoded form. Use the ANSI/MBCS library versions of MFC for UTF-8 encoded Unicode support.
To set your project configuration to use single-byte, multibyte, or wide-character Unicode string and character support in the IDE, use the Project Properties dialog. In the Configuration Properties > General page, set the Character Set property to Not Set to use a single-byte character set. Set the property to Use Multi-Byte Character Set to use a multibyte character set, or to Use Unicode Character Set to use Unicode encoded as UTF-16.
MFC projects use the preprocessor symbol _UNICODE to indicate UTF-16 wide-character Unicode support, and _MBCS to indicate MBCS support. These options are mutually exclusive in a project.
MFC static library naming conventions
Static libraries for MFC use the following naming conventions. The library names have the form
uAFXcd.LIB
where the letters shown in italic lowercase are placeholders for specifiers whose meanings are shown in the following table:
Specifier
Values and meanings
u
ANSI/MBCS (N) or Unicode (U); omit for version without MFC controls in dialogs
c
Version with MFC controls in dialogs (CW) or without (NMCD)
d
Debug or Release: D=Debug; omit specifier for Release
All libraries listed in the following table are included prebuilt in the \atlmfc\lib directory for supported build architectures.
Library
Description
NAFXCW.LIB
MFC Static-Link Library, Release version
NAFXCWD.LIB
MFC Static-Link Library, Debug version
UAFXCW.LIB
MFC Static-Link Library with Unicode support, Release version
UAFXCWD.LIB
MFC Static-Link Library with Unicode support, Debug version
AFXNMCD.LIB
MFC Static-Link Library without MFC dialog controls, Release version
AFXNMCDD.LIB
MFC Static-Link Library without MFC dialog controls, Debug version
Debugger files that have the same base name and a .pdb extension are also available for each of the static libraries.
MFC shared DLL naming conventions
The MFC shared DLLs also follow a structured naming convention. This makes it easier to know which DLL or library you should be using for which purpose.
The MFC DLLs have version numbers that indicate binary compatibility. Use MFC DLLs that have the same version as your other libraries and compiler toolset to guarantee compatibility within a project.
DLL
Description
MFCversion.DLL
MFC DLL, ANSI or MBCS Release version
MFCversionU.DLL
MFC DLL, Unicode Release version
MFCversionD.DLL
MFC DLL, ANSI or MBCS Debug version
MFCversionUD.DLL
MFC DLL, Unicode Debug version
MFCMversion.DLL
MFC DLL with Windows Forms controls, ANSI or MBCS Release version
MFCMversionU.DLL
MFC DLL with Windows Forms controls, Unicode Release version
MFCMversionD.DLL
MFC DLL with Windows Forms controls, ANSI or MBCS Debug version
MFCMversionUD.DLL
MFC DLL with Windows Forms controls, Unicode Debug version
The import libraries needed to build applications or MFC extension DLLs that use these shared DLLs have the same base name as the DLL but have a .lib file name extension. When you use the shared DLLs, a small static library must still be linked with your code; this library is named MFCSversion{U}{D}.lib.
If you are dynamically linking to the shared DLL version of MFC, whether it is from an application or from an MFC extension DLL, you must include the matching MFCversion.DLL or MFCversionU.DLL when you deploy your product.
You can use either the static or shared dynamic MFC libraries to create DLLs that can be used by both MFC and non-MFC executables. These are called "regular DLLs" or "regular MFC DLLs", to distinguish them from MFC extension DLLs that can only be used by MFC apps and MFC DLLs. A DLL built by using the MFC static libraries is sometimes called a USRDLL in older references, because MFC DLL projects define the preprocessor symbol _USRDLL. A DLL that uses the MFC shared DLLs is sometimes called an AFXDLL in older references, because it defines the preprocessor symbol _AFXDLL.
When you create your DLL project by linking to the MFC static libraries, your DLL can be deployed without the MFC shared DLLs. When your DLL project links to the import libraries MFCversion.LIB or MFCversionU.LIB, you must deploy the matching MFC shared DLL MFCversion.DLL or MFCversionU.DLL together with your DLL. For more information, see DLLs.
Windows developers have various options for creating applications that run on Windows. This module introduces the native Windows UI frameworks that are available for Windows development. It also provides guidance on how to choose the best framework for your application.