MBCS 使用 Visual Studio 构建 MFC C++ 项目时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19603680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 22:59:29  来源:igfitidea点击:

MBCS Error building MFC C++ project with Visual Studio

c++visual-studio-2013mfcvisual-studio-2015mbcs

提问by Raman Sharma

I opened my existing MFC project using Visual Studio and when I build I get the following error message:

我使用 Visual Studio 打开了我现有的 MFC 项目,当我构建时,我收到以下错误消息:

Error 1 error MSB8031: Use of MBCS encoding in MFC projects require an additional library to be downloaded and installed. Please see http://go.microsoft.com/fwlink/?LinkId=286820 for more information. C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\v120\Microsoft.CppBuild.targets

What is this about?

这是关于什么的?

回答by Raman Sharma

This error message is due to the missing MBCS MFC package. Starting with Visual Studio 2013, MBCS portion of the MFC library has been broken out of the Visual Studio product into its own separate download. Installing this package and rebuilding should fix the problem.

此错误消息是由于缺少 MBCS MFC 包造成的。从 Visual Studio 2013 开始,MFC 库的 MBCS 部分已从 Visual Studio 产品中分离出来,单独下载。安装这个包并重建应该可以解决这个问题。

  • The download is available here
  • More information about this change is available here

Update for Visual Studio 2015

Visual Studio 2015 更新

Starting with Visual Studio 2015, the entire MFC C++ library (including the MBCS pieces) is an optional install component. While installing VS2015, if you select C++ and MFC, you will also get the MBCS library.

从 Visual Studio 2015 开始,整个 MFC C++ 库(包括 MBCS 部分)是一个可选的安装组件。安装VS2015时,如果选择C++和MFC,也会得到MBCS库。

回答by ragnarius

Instead of installing an add-on, you may consider changing the character set from MBCS to Unicode.

您可以考虑将字符集从 MBCS 更改为 Unicode,而不是安装附加组件。

This is done in the project properties as is depicted below. project properties

这是在项目属性中完成的,如下所示。 项目属性

回答by tibx

For Visual Studio 2015:

对于Visual Studio 2015

According to Redistributing the MFC Libraryarticle on MSDN, there are no mfc140.dll files in redist directory (c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86).

根据MSDN 上的重新分发 MFC 库文章,redist 目录 (c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86) 中没有 mfc140.dll 文件。

The mfc140.dll files were omitted from the redistributable files directory in Visual Studio 2015 RTM. You can use the versions installed by Visual Studio 2015 in the Windows\system32 and Windows\syswow64 directories instead.

Visual Studio 2015 RTM 的可再发行文件目录中省略了 mfc140.dll 文件。您可以改用 Visual Studio 2015 安装在 Windows\system32 和 Windows\syswow64 目录中的版本。