gpt4 book ai didi

c++ - 错误 LNK2038 : mismatch detected for '_MSC_VER' : value '1600' doesn't match value '1700' in CppFile1. 对象

转载 作者:太空宇宙 更新时间:2023-11-04 13:09:00 25 4
gpt4 key购买 nike

我正在将我的项目从 VS2010 转换到 VS2012。但是我在某些项目中遇到了 _MSC_VER 链接器错误。经过长时间的谷歌搜索后,我发现问题是由于将 VS2010 中创建的库链接到 VS2012 造成的。

如何找出导致错误的项目?这里我引用错误:

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

最佳答案

TL;DR; 使用当前编译器(VS2012,在 OP 的情况下)重新编译所有旧的 static-linked .lib 文件。


您正在尝试链接由不同版本的编译器编译的对象。这在现代版本的 VS 中不受支持,至少如果您使用的是 C++ 标准库则不支持。标准库的不同版本是二进制不兼容的,因此您需要链接器的所有输入都使用相同的版本进行编译。确保重新编译所有要链接的对象。

编译器错误命名了涉及的对象,因此问题的信息已经有了您正在寻找的答案。具体来说,您链接的静态库似乎需要重新编译。

所以解决方案是用VS2012重新编译Projectname1.lib。

You can link to older .lib files only if:

  • If they are not static-linked, and come with an already compiled .dll file (or .exe file).
  • Or if the two standard-libraries are binary-compatible (which they are not in OP's case).

关于c++ - 错误 LNK2038 : mismatch detected for '_MSC_VER' : value '1600' doesn't match value '1700' in CppFile1. 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40816796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com