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

tjdoubts picture tjdoubts · Oct 24, 2013 · Viewed 138.6k times · Source

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

Answer

David Heffernan picture David Heffernan · Oct 24, 2013

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.