gpt4 book ai didi

c++ - 版本号、次要号和发布号之间的区别

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:45:41 27 4
gpt4 key购买 nike

我正在阅读 http://www.tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html我有一些问题。
版本号、次要版本号和发布号之间有什么区别? “每当界面更改时版本号都会增加”部分是什么意思?

The soname has the prefix lib, the name of the library, the phrase .so, followed by a period and a version number that is incremented whenever the interface changes.

The real name adds to the soname a period, a minor number, another period, and the release number.

最佳答案

每次发布库时,它都应该有不同的版本号。但是,某些版本仅对库的内部工作进行更改,而不会影响用户,除了修复错误。其他版本也可能会向库中添加新功能,但所有现有功能的接口(interface)细节与以前相同,因此使用旧版本库编写的软件将继续使用新版本。其他更改可能会破坏向后兼容性;一个函数接口(interface)改变,一个结构改变大小,或者一个函数被删除(或者一个全局变量——消除思想——改变,等等)。

'bug fix only' 版本可能不会为库重新编号而烦恼,但如果你以前有 liberror.so.1.0.2 ,新版本可能是liberror.so.1.0.3 ,版本号的变化。

'附加功能' 版本应该被赋予一个新的次要编号,所以 liberror.so.1.0.2 之后的新版本可能是 liberror.so.1.1.0 .

如果你破坏了兼容性,那么你使用一个新的版本号,所以 liberror.so.1.0.2 之后的新版本可能是 liberror.so.2.0.0 .

为使用而构建的代码 liberror.so.1.0.2可以并且将使用liberror.so.1.0.3liberror-1.1.0没有问题,但不会尝试使用liberror.so.2.0.0或更高版本。

What code (in a GNU binutils stack, for example) controls which versions will be linked to, and is this behavior fixed or overridable?



好问题。这是我的理解,但我可能有一些细节错误(在这种情况下,有人可能会指出我的方式错误)。上面的理论很好很简单;这不太容易。

您可能已经注意到,有库的“开发”包以及库的“标准”版本。它们之间的差异是解释的一部分。

如果您是一个普通的最终用户,他不使用库编写程序,而只是运行其他人编写的程序,那么您通常会在安装目录中得到一个文件和一个符号链接(symbolic link)。继续假设 liberror.so.1.0.2例如(安装在 /usr/local/lib 中),您会在基本版本中找到:
liberror.so.1.0.2   — the real shared object
liberror.so.1 — symlink to the the real shared object

如果您安装了开发版,您可能会在 /usr/local/include 中找到一些头文件。 ,一些手册页(可能在 /usr/local/man 中,也可能在 /usr/share 中),以及一个额外的符号链接(symbolic link):
liberror.so         — another symlink, either to liberror.so.1 or to liberror.so.1.0.2

编译使用它的程序时,您可以指定:
gcc -I/usr/local/include usererror.c -o usererror -L/usr/local/lib -lerror

这将链接到名称 liberror.so ,但从 liberror.so.1.0.2 读取元数据文件,它会知道要使用的版本是 liberror.so.1.0.2或更高版本(但不是 liberror.so.2.0.0 或更高版本)。

现在假设您将安装升级到 liberror.so.2.0.0 .您现在有文件:
liberror.so.1.0.2   — the real shared object
liberror.so.1 — symlink to the the real shared object
liberror.so.2.0.0 — the real shared object
liberror.so.2 — symlink to the the real shared object
liberror.so — another symlink, either to liberror.so.2 or to liberror.so.2.0.0

为使用而构建的旧代码 liberror.so.1仍然使用该库运行。为使用而构建的新代码 liberror.so.2也使用新库运行。并且在链接时间,新程序拿起 liberror.so.2.0.0通过符号链接(symbolic link) liberror.so .

您可以控制它,使系统上的默认值仍然是 liberror.so.1通过调整 liberror.so指向 liberror.so.1.0.2 的符号链接(symbolic link).唯一棘手的部分是确保头文件的正确版本可用于编译。使用 liberror.so.2 的 header 构建是个坏主意并链接到 liberror.so.1因为您肯定知道的一件事是界面不同!

来自 Red Hat Enterprise Linux 5 (RHEL5) x86_64 机器的一些原始数据。
$ cd /lib64
$ ls libc*
-rwxr-xr-x 1 root root 1713088 2009-01-05 16:32 libc-2.5.so
lrwxrwxrwx 1 root root 11 2012-02-22 15:05 libcap.so -> libcap.so.1
lrwxrwxrwx 1 root root 14 2012-02-22 15:05 libcap.so.1 -> libcap.so.1.10
-rwxr-xr-x 1 root root 17384 2006-11-14 01:36 libcap.so.1.10
-rwxr-xr-x 1 root root 197744 2009-01-05 16:32 libcidn-2.5.so
lrwxrwxrwx 1 root root 14 2012-02-22 15:05 libcidn.so.1 -> libcidn-2.5.so
lrwxrwxrwx 1 root root 17 2012-02-22 15:05 libcom_err.so.2 -> libcom_err.so.2.1
-rwxr-xr-x 1 root root 10000 2008-09-30 13:27 libcom_err.so.2.1
-rwxr-xr-x 1 root root 48600 2009-01-05 16:32 libcrypt-2.5.so
-rwxr-xr-x 1 root root 1048728 2005-10-31 06:47 libcrypto.so.0.9.6b
-rwxr-xr-x 1 root root 1365504 2008-12-16 08:09 libcrypto.so.0.9.8e
lrwxrwxrwx 1 root root 19 2012-02-22 15:05 libcrypto.so.2 -> libcrypto.so.0.9.6b
lrwxrwxrwx 1 root root 19 2012-02-22 15:05 libcrypto.so.4 -> libcrypto.so.0.9.8e
lrwxrwxrwx 1 root root 19 2012-02-22 15:05 libcrypto.so.6 -> libcrypto.so.0.9.8e
lrwxrwxrwx 1 root root 15 2012-02-22 15:05 libcrypt.so.1 -> libcrypt-2.5.so
lrwxrwxrwx 1 root root 11 2012-02-22 15:05 libc.so.6 -> libc-2.5.so
$

你可以看到 libc.so.6libc-2.5.so 的符号链接(symbolic link).您还可以使用多个版本的 libcrypto ,不包括链接时库 libcrypto.so .您还可以看到只有两个部分的库版本号等。表示的库是 libc , libcap , libcidn , libcom_err , libcryptlibcrypto .

关于c++ - 版本号、次要号和发布号之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15454516/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com