C++ 错误 LNK2038:检测到“_MSC_VER”不匹配:值“1600”与 CppFile1.obj 中的值“1700”不匹配
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19575747/
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
error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj
提问by tjdoubts
I was converting my projects from VS2010 to VS2012.But I am getting an _MSC_VER linker error in certain projects. After a long surfing through google I found out that the issue is due to linking of a library created in VS2010 to VS2012.
我正在将我的项目从 VS2010 转换为 VS2012。但是我在某些项目中遇到了 _MSC_VER 链接器错误。通过谷歌长时间浏览后,我发现问题是由于将在 VS2010 中创建的库链接到 VS2012。
How can I find out that which projectis causing the error? Here I am quoting the error:
如何找出导致错误的项目?我在这里引用错误:
Error 6 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile2.obj) Projectname2
Error 15 error LNK2001: unresolved external symbol "private: static void __cdecl std::locale::facet::_Facet_Register(class std::locale::facet *)" (?_Facet_Register@facet@locale@std@@CAXPAV123@@Z) D:\ProjectLocation\Projectname1.lib(CppFile3.obj) Projectname2
Error 13 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile4.obj) Projectname2
Error 12 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile5.obj) Projectname2
Error 10 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile6.obj) Projectname2
Error 11 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile7.obj) Projectname2
Error 9 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile8.obj) Projectname2
Error 4 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile9.obj) Projectname2
Error 14 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile10.obj) Projectname2
Error 7 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile11.obj) Projectname2
Error 8 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile12.obj) Projectname2
Error 5 error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj D:\ProjectLocation\Projectname1.lib(CppFile13.obj) Projectname2
回答by David Heffernan
You are trying to link objects compiled by different versions of the compiler. That's not supported in modern versions of VS, at least not if you are using the C++ standard library. Different versions of the standard library are binary incompatible and so you need all the inputs to the linker to be compiled with the same version. Make sure you re-compile all the objects that are to be linked.
您正在尝试链接由不同版本的编译器编译的对象。这在 VS 的现代版本中不受支持,至少在您使用 C++ 标准库时不支持。标准库的不同版本是二进制不兼容的,因此您需要使用相同版本编译链接器的所有输入。确保重新编译所有要链接的对象。
The compiler error names the objects involved so the information the the question already has the answer you are looking for. Specifically it seems that the static library that you are linking needs to be re-compiled.
编译器错误命名了所涉及的对象,因此问题的信息已经包含您正在寻找的答案。具体来说,您正在链接的静态库似乎需要重新编译。
So the solution is to recompile Projectname1.lib with VS2012.
所以解决办法是用VS2012重新编译Projectname1.lib。
回答by Ahmed U3
for each project in your solution make sure that
对于解决方案中的每个项目,请确保
Properties > Config. Properties > General > Platform Toolset
属性 > 配置。属性 > 常规 > 平台工具集
is one for all of them, v100 for visual studio 2010, v110 for visual studio 2012
是其中之一,适用于 Visual Studio 2010 的 v100,适用于 Visual Studio 2012 的 v110
you also may be working on v100 from visual studio 2012
您也可能正在使用 Visual Studio 2012 的 v100
回答by Jinxi
I was importing also some projects from VS2010 to VS 2012. I had the same errors. The errors disappeared when I set back Properties > Config. Properties > General > Platform Toolset to v100 (VS2010). That might not be the correct approach, however.
我也将一些项目从 VS2010 导入到 VS 2012。我遇到了同样的错误。当我设置回“属性”>“配置”时,错误消失了。属性 > 常规 > 平台工具集到 v100 (VS2010)。然而,这可能不是正确的方法。
回答by Hai Tran
I upgraded from 2010 to 2013 and after changing all the projects' Platform Toolset, I need to right-click on the Solution and choose Retarget... to make it work.
我从 2010 年升级到 2013 年,在更改了所有项目的平台工具集后,我需要右键单击解决方案并选择重新定位...以使其工作。