error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj

143,183

Solution 1

TL;DR; Recompile all your old static-linked .lib files with current-compiler (VS2012, in OP's case).


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.

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.

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).

Solution 2

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

you also may be working on v100 from visual studio 2012

Solution 3

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.

Solution 4

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.

Share:
143,183
mystack
Author by

mystack

Updated on June 01, 2020

Comments

  • mystack
    mystack almost 4 years

    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.

    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
    
  • mystack
    mystack over 10 years
    Thank you David, What you are saying is the issue is with the cpp files? I have done all modification with the project files by adding the <PlatformToolset>v110</PlatformToolset>.SO i think the issue may not be with the Project file,isn't it?
  • David Heffernan
    David Heffernan over 10 years
    No, it's the object files. What the compiler emits. They appear to be inside the .lib file. You'll need to recompile it.
  • mystack
    mystack over 10 years
    Hi David, iam new to c++ .Iam basically a c# programmmer. Can you please elaborate the comments
  • David Heffernan
    David Heffernan over 10 years
    The compiler is telling you to recompile Projectname1.lib with VS2012.
  • drescherjm
    drescherjm over 9 years
    This should not be an answer but a new question.
  • sergiol
    sergiol over 8 years
    Where is that setting for C# projects?
  • sergiol
    sergiol over 8 years
    In my case, the lib file was not even compiling, giving the error "program database file, 'vc80.pdb', has an obsolete format, delete it and recompile". I did what the compiler recommended and now it is compiling both the lib and the project that depends on the lib.
  • mr3
    mr3 almost 8 years
    Another gotcha here: dependent libraries. You can run into the same issue with pre-built APIs/SDKs/etc, especially if you're stepping up your compiler for your own app(s) and forgetting to step up libraries you depend on to match them...like I just did ;)
  • Cary
    Cary over 6 years
    @sergiol, the PlatformToolset attribute is a MSBuild attribute which is used to specify the version of C++ toolset. So this attribute has nothing to do with C#.
  • deetz
    deetz over 3 years
    Is there any way to make it work? I have a VS 2013 Project but I need to use boost libraries that work only for VS 2015 and newer.