问题描述
我有两种情况.假设我有3个共享库,它们导出C ++符号,每个共享库都用VS7.1,VS8和VS9构建.我在VS9中全部编译了3个.由于某种原因,这行得通.我不需要为VS9链接器重新编译VS9中的前2个库即可成功找到符号并针对它们进行链接.
I have two scenarios. Suppose I have 3 shared libraries that export C++ symbols, each built with VS7.1, VS8, and VS9. I compile all 3 in VS9. For some reason, this works. I do not need to recompile the first 2 libraries in VS9 for VS9 linker to successfully find the symbols and link against them.
现在,如果我有一个仅使用C语法导出符号的库(外部"C"),是否一样?我听说有人说ABI for C是标准化的,因此可以保证在所有版本的Visual Studio中都可以使用在Visual Studio 8中编译的C库.
Now, if I have a library that only exports symbols using C syntax (extern "C"), is this the same? I've heard people say that the ABI for C is standardized, so there is somewhat of a guarantee that you can use a C library compiled in Visual Studio 8 in all versions of Visual Studio.
基本上,所有这些东西的组合令人困惑.我不确定在不同版本的Visual Studio之间链接到C ++和基于C的共享库(使用它们相应的导入库)之间有什么保证.我想听听有关C 和 C ++导入或任何其他版本的Visual Studio上的静态库的向前/向后兼容性的普遍共识.
Basically, the combination of all of these things is confusing. I'm not sure of what guarantees I have between linking against both C++ and C based shared libraries (using their corresponding import libraries) between different versions of Visual Studio. I'd like to hear the general consensus on both forward/backward compatibility of both C AND C++ import or static libraries on any other version of Visual Studio.
之所以出现这种情况,是因为我使用的是封闭源代码库,这些库是在Visual Studio .NET 2003(VS7.1)中编译的.我的团队认为这将我们锁定到VS 7.1编译器,但是我已经走出去并在VS8和VS9(甚至是VS2010)中测试了这些库,并且它们可以很好地链接.但是,我不确定其中存在固有的危险.请注意,所讨论的库具有C变体和C ++变体.基本上,C变体是标准C导出,而C ++库是对C库和导出类的抽象.
The reason this has come up for me is because there are closed-source libraries I'm using that were compiled in Visual Studio .NET 2003 (VS7.1). My team thinks that this locks us to the VS 7.1 compiler, however I've gone out and tested these libraries in both VS8 and VS9, even VS2010 and they link just fine. However, I'm not sure of the inherent danger in this. Note that the library in question has a C variant and a C++ variant. Basically, the C variant is standard-C exports, and the C++ library is an abstraction over the C library and exports classes.
推荐答案
问题不仅可能是这些VS版本之间的ABI差异(调用约定等),而且还可能是系统DLL库中已删除/更改的符号中的问题.有关系统DLL的详细比较,请参见此表. VS8(2005,Windows SDK 5.0)和VS9(2008,Windows SDK 6.0)之间的库.
The issue may be not only in ABI differences (calling conventions, etc.) between these VS versions, but also in removed/changed symbols in system DLL libraries. See this table for the detailed comparison of system DLL libraries between VS8 (2005, Windows SDK 5.0) and VS9 (2008, Windows SDK 6.0).
另请参阅Windows SDK的兼容性矩阵.
See also compatibility matrix for Windows SDKs.
这篇关于Visual Studio版本之间的库ABI兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!