是否使用不同版本的Visual Studio创建的C ++ lib与彼此兼容?

问题描述:

我使用Visual Studio 2005创建了一个开源的C ++库。我想提供预编译的lib和源代码。这些库是用VS2005构建的,还将使用较新版本的Visual Studio(esp VS Express Edition 2008)?或者我需要为每个VS版本提供单独的库?

I am creating a open-source C++ library using Visual Studio 2005. I would like to provide prebuilt libs along with the source code. Are these libs, built with VS2005, also going to work with newer versions of Visual Studio (esp VS Express Edition 2008)? Or do I need to provide separate libs per VS version?

如果您正在分发静态库,版本无关的库,这取决于你在做什么。如果你只打电话到操作系统,那么你可能会OK。 C RTL函数,也许。但如果你使用任何C ++标准库函数,类或模板,那么可能不是。

If you are distributing static libraries, you may be able to distribute version-independent libraries, depending on exactly what you are doing. If you are only making calls to the OS, then you may be OK. C RTL functions, maybe. But if you use any C++ Standard Library functions, classes, or templates, then probably not.

如果分发DLL,你将需要为每个VS版本的单独的库。有时候,甚至需要单独的库用于各种服务包级别。正如VolkerK所提到的,你的库的用户必须使用兼容的编译器和链接器设置。

If distributing DLLs, you will need separate libraries for each VS version. Sometimes you even need separate libraries for various service-pack levels. And as mentioned by VolkerK, users of your library will have to use compatible compiler and linker settings.

由于这些问题,而不是花费时间来建立所有这些库对于您的用户,我花费时间使其尽可能轻松地构建,以便用户可以自己构建他们自己的最小的麻烦。

Due to these issues, instead of spending time trying to build all these libraries for your users, I'd spend the time making it as easy to build as possible, so that users can can build them on their own with minimal fuss.