How to change MFC Library Version

Michael Tadyshak 20 Reputation points

I have a MFC program that was built using VS 2008. Now I am trying to build it with VS 2022. Everything compiles OK but it fails because it cannot find MFC90.lib. The solution was converted by VS 2022. I am trying to use mfc140.dll and mfc140.lib. The macro in afx.h _MFC_FILENAME_VER is set correctly as 140.

The *.vcproj project file has a reference to version 9.0 (see below) - but I don't think that project file is used anymore and is replaced by the *.vcxproj project file.

ProjectType="Visual C++"

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,181 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To change the MFC library version, you need to edit the linker list of libraries. Change NAFXCWD.LIB to MFCxxD.LIB and change NAFXCW.LIB to MFCxx.LIB. Replace LIBC.LIB with MSVCRT.LIB. As with any other MFC library, it's important that MFCxxD.LIB is placed before any C-runtime libraries. If you're using the internal makefile with most of the standard defaults, you can easily change the project to build the DLL version. On the Projects menu, select Properties. In the General page under Project Defaults, set Microsoft Foundation Classes to Use MFC in a Shared DLL (MFCxx(d).dll). If you're using the external makefile feature of the compiler, or are using NMAKE directly, you'll have to edit your makefile to support required compiler and linker options. Required compiler flags: /D_AFXDLL /MD. The standard MFC headers need the _AFXDLL symbol to be defined. /MD. The application must use the DLL version of the C run-time library. All other compiler flags follow the MFC defaults (for example, _DEBUG for debug).


    0 comments No comments

  2. RLWA32 34,806 Reputation points

    As described in 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."

    If the C++ project file (.vcxproj) generated when an old VS2008 MFC project was converted contains references to the old MFC libraries in the linker property pages you can remove them. You can also review your source code for any #pragma directives that refer to the old libraries.

    0 comments No comments