简体   繁体   中英

Upgrading VS2017 15.2 to 15.3 broke third party libraries

I recently updated my Visual Studio version to the latest (mostly because of an automatic update rather than me willingly doing so). This proceeded to break my compiler when linking in third party libraries that were built using 15.2 instead of the current version of 15.3. The error I'm seeing is:

"Library_Name_here.lib" was created with an older compiler than other objects; rebuild old objects and libraries

I am looking for either ideas for solutions to avoid a re-compile of these libraries, but if one does not exist, I am looking for a way to compile the libraries to be version agnostic to not have to keep recompiling every time that vs updates.

It is not a good idea to mix and match code (object files or static libraries) compiled by different versions of the compiler in the same binary.

To quote MSDN on that:

To avoid run-time errors that are difficult to detect and diagnose, we recommend that you never statically link to binaries that were compiled by using different versions of the compiler. Also, when you upgrade an EXE or DLL project, make sure to upgrade the libraries that it links to. If you're using CRT (C Runtime) or STL (Standard Template Library) types, don't pass them between binaries (including DLLs) that were compiled by using different versions of the compiler. For more information, see Potential Errors Passing CRT Objects Across DLL Boundaries .

The solution is therefore to recompile all third-party static libraries with the new compiler.

I also had issues few months ago when i upgraded VS2015 to VS2017 and one of my big project that i was running on visual studio 2015 stopped working. That project had several class libraries and external DLLs added.

So what I did was, Uninstalled the upgraded version of visual studio 2017 and re-installed the complete visual studio 2017 from MSDN website (selecting the default selection of features). And then i loaded my Project in VS2017 fresh copy and added the reference of all external libraries and it worked.

I suggest you to try the same

This is a shot in the dark, based on this other SO answer: Error C1047: Object file created with an older compiler than other objects

Recompile the other library without link time code generation enabled ( /GL and /LTCG ). With it enabled the library expects the linker to do most of the compiling, and you cannot expect one version of the compiler to finish the compiling another version started.

Do not disable it in your active project, as it improves performance significantly. Just in the library.

Major compiler versions may still require rebuilding the 3rd party library, but not minor.

You can do this from within VS2017. It allows you to use tool sets going all the way back to VS2008

See this for details!

https://blogs.msdn.microsoft.com/vcblog/2016/02/24/stuck-on-an-older-toolset-version-move-to-visual-studio-2015-without-upgrading-your-toolset/

Hope that helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM