Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes the MSB8041 error code.
Message text
MSB8041: MFC/ATL Libraries are required for this project.
Description
This error occurs when the project requires Microsoft Foundation Classes (MFC) or the Active Template Library (ATL), but the libraries aren't found. MFC and ATL libraries aren't installed by default when you install a C++ workload in Visual Studio.
Resolution
Verify the correct versions of MFC and ATL libraries for your build toolset are installed. There are versions of MFC for each version of the C++ build tools, for each target platform, and with or without Spectre mitigations. For example, C++ MFC for latest v143 build tools (x86 and x64) has the x86 and x64 libraries without Spectre mitigations for the latest version of Visual Studio 2022 (v143). If you simply want to use the latest libraries for a given version of a Visual Studio toolset, you need C++ MFC for latest [version] build tools ([target]) for non-Spectre builds and C++ MFC for latest [version] build tools with Spectre Mitigations ([target]) for Spectre mitigated builds. Choose the correct option for your target platform architecture. The other options support scenarios for specific targeting of an earlier toolset. For more information, see MFC Library Versions.
Install MFC and ATL libraries
Open the Visual Studio Installer.
Select the Modify button next to the version of Visual Studio you use.
Select the Individual components tab at the top of the dialog.
In the Search components box, enter MFC.
Select the MFC components that match your project targets, such as x86 or ARM64EC. Select the components with Spectre mitigations if you build your projects with Spectre mitigations enabled.
In most cases, you want to select MFC for the latest build tools. Your organization or project might require a specific earlier version of the toolset. Make sure the version, targets, and Spectre mitigations of the MFC components you install match the toolset version, targets, and Spectre mitigations required by the project you're building.
In the Search components box, enter ATL.
Select the ATL components that match your project targets, such as x86 or ARM64EC. Select the components with Spectre mitigations if you build your projects with Spectre mitigations enabled.
In most cases, you want to select ATL for the latest build tools. Your organization or project might require a specific earlier version of the toolset. Make sure the version, targets, and Spectre mitigations of the ATL components you install match the toolset version, targets, and Spectre mitigations required by the project you're building.
Select Modify to install the selected components.
For more information about modifying Visual Studio to install the libraries and binaries you need, see Modify Visual Studio.
Explore advanced diagnostics
For detailed build troubleshooting, the MSB8041 error is triggered in the C++ build process in the MSBuild target Microsoft.CppBuild.targets when the following file isn't found: $(VCToolsInstallDir)atlmfc\lib\$(_SpectreLibsDir)$(PlatformShortName)\mfcs140.lib
. The properties come from the environment ($(VCToolsInstallDir)
) and the project configuration: $(_SpectreLibsDir)
is empty or spectre\
, $(PlatformShortName)
is x86
, x64
, arm
, arm64
, or arm64EC
.
Applies to
All versions of MSBuild