简体   繁体   中英

Visual Studio 2015 vs 2012

  • Can a static library compiled in VS 2015 can be used in VS 2012? The C compiler of VS 2012 is very old. The most common problem I encounter is the variable declaration location. A variable has to be declared in the beginning of its scope in VS 2012.

  • If there is such a compatibility then I just need to fix compilation errors in header files and call the functions from the library. Is that right?

In general, static libraries are not compatible between different versions of Visual Studio.

https://en.wikipedia.org/wiki/Visual_C%2B%2B#Compatibility

The Visual C++ compiler ABI have historically changed between major compiler releases. This is especially the case for STL containers, where container sizes have varied a lot between compiler releases. Microsoft therefore recommends against using C++ interfaces at module boundaries when one wants to enable client code compiled using a different compiler version. Instead of C++, Microsoft recommends using C or COM interfaces, which are designed to have a stable ABI between compiler releases.

I have not specifically tried doing VS2015 -> VS2012, but going the other way definitely has some issues (VS2012/VS2013 -> VS2015). However, in VS2015, there are undocumented libraries (legacy_stdio_definitions.lib and legacy_stdio_wide_specifiers.lib) which attempt to mitigate some specific problems, but they aren't a catch-all for compatibility.

The best solution is to compile the static library with the version of Visual Studio you intend to consume it in.

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