Visual Studio 2015: v120 vs v140?

2019-05-02 11:23发布

问题:

FYI: Win10, x64

I started trying out Visual Studio 2015 today, and after figuring out how to get the C/C++ parts running I tried to load up a big personal project that uses the unofficial glsdk. I tried to build and got linker errors. It complained about unresolved external symbols being referenced in freeglutD.lib, glloadD.lib, and glutil.lib. It also complained about _MSC_VER mismatches in my own files.

I did some research online, messed around with 2013 and compiler versions (project properties -> General -> Platform Toolset)) - v120 for 2013 and v140 for 2015 - and was able to rebuild glsdk with v140 (excluding glmesh due to a missing file). Then...it worked fine.

Question: Why is this? I thought that a static lib file created by a standard-compliant compiler would work with other versions of a standard-compliant compiler (in this case, C/C++ on v120 and C/C++ on v140). But apparently v140 would not play ball with libraries made by a previous compiler.

If this is just the dark lands of VS build routines, then I can drop the question, but I'd also like to know why they don't work together.

回答1:

Historically, Visual C++ has broken binary compatibility between the run-time libraries at each major version. This provides some freedom to improve implementations without being constrained by the ABIs of previous versions.

Starting with Visual C++ 2015, however, they've re-architected the run-time libraries in a way that should allow them to provide compatibility going forward, but this doesn't solve the problem going backwards.

See this blog post and the few follow-ups they've posted about the "Universal CRT."