C++ 库兼容性

标签 c++ gcc compiler-construction binary-compatibility

我目前正在编写一个库,并且正在考虑从 GCC 4.1.2 迁移到 GCC 4.5.2(最新版本)。如果我将我的代码编译成静态库,我是否可以假设编译器兼容性(显然在同一操作系统上)对客户来说应该不是问题?

编辑 进一步澄清:如果我向客户提供一个使用 gcc 4.5.2 编译的静态链接库,那么就他们必须使用的编译器和版本而言,这对该库的用户有什么限制?

最佳答案

刚刚发现这个我相信它回答了我来自 http://gcc.gnu.org/bugs/#nonbugs 的问题:

ABI changes The C++ application binary interface (ABI) consists of two components: the first defines how the elements of classes are laid out, how functions are called, how function names are mangled, etc; the second part deals with the internals of the objects in libstdc++. Although we strive for a non-changing ABI, so far we have had to modify it with each major release. If you change your compiler to a different major release you must recompile all libraries that contain C++ code. If you fail to do so you risk getting linker errors or malfunctioning programs. Some of our Java support libraries also contain C++ code, so you might want to recompile all libraries to be safe. It should not be necessary to recompile if you have changed to a bug-fix release of the same version of the compiler; bug-fix releases are careful to avoid ABI changes. See also the compatibility section of the GCC manual.

Remark: A major release is designated by a change to the first or second component of the two- or three-part version number. A minor (bug-fix) release is designated by a change to the third component only. Thus GCC 3.2 and 3.3 are major releases, while 3.3.1 and 3.3.2 are bug-fix releases for GCC 3.3. With the 3.4 series we are introducing a new naming scheme; the first release of this series is 3.4.0 instead of just 3.4.

据我所知,我需要确保客户将我的库与 gcc 的主要版本兼容版本链接起来。

关于C++ 库兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4705769/

相关文章:

c++ - 比较字符串中的符号时出现 std::out_of_range 错误

c++ - 如何恢复停止的进程?

C++ 为有限数量设置的所有变体编译代码

c++ - 未记录的 GCC C++11 扩展?在 lambda 捕获列表中捕获任意表达式

c++ - 继承构造函数

c - 根据内存位置的特定值定义值

c++ - 包含在 Linux GCC 链接器中

gcc - 为什么丢失的共享库会致命?

java - "someString"相当于新字符串 ("someString"吗?在java中

c# - Visual Studio 调试器 - 有什么方法可以通过调试器访问编译器生成的临时变量?