72

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
meJustAndrew
  • 6,011
  • 8
  • 50
  • 76
mystack
  • 4,910
  • 10
  • 44
  • 75

4 Answers4

96

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).
Top-Master
  • 7,611
  • 5
  • 39
  • 71
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 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 v110.SO i think the issue may not be with the Project file,isn't it? – mystack Oct 24 '13 at 20:28
  • 2
    No, it's the object files. What the compiler emits. They appear to be inside the .lib file. You'll need to recompile it. – David Heffernan Oct 24 '13 at 20:40
  • Hi David, iam new to c++ .Iam basically a c# programmmer. Can you please elaborate the comments – mystack Oct 24 '13 at 20:43
  • 5
    The compiler is telling you to recompile Projectname1.lib with VS2012. – David Heffernan Oct 24 '13 at 20:48
  • 1
    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. – sergiol Sep 15 '15 at 10:51
  • 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 ;) – mr3 May 29 '16 at 17:09
  • 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. – deetz Aug 21 '20 at 09:21
42

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

Ahmed U3
  • 698
  • 5
  • 9
  • Where is that setting for C# projects? – sergiol Sep 15 '15 at 09:44
  • @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#. – Cary Nov 14 '17 at 15:45
4

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.

dandan78
  • 13,328
  • 13
  • 64
  • 78
Jinxi
  • 303
  • 1
  • 13
3

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.

Hai Tran
  • 31
  • 1