gpt4 book ai didi

linux - 链接符号链接(symbolic link)而不是soname

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:29:57 26 4
gpt4 key购买 nike

我有一个 linux 应用程序,它在链接器行上链接到:libpython2.6.so

这最终解析为 libpython.2.6.so.1.0

/usr/lib/libpython2.6.so -> libpython2.6.so.1
/usr/lib/libpython2.6.so.1 -> libpython2.6.so.1.0

其中嵌入了 SONAME,因此我坚持使用它链接到完全版本化的名称。

 g++ foo.cc /usr/lib/libpython2.6.so
ldd ./a.out | grep python
libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00007fd36f7ab000)

这意味着如果有 libpython2.6.so.1.1,我的应用程序最终将崩溃。无论如何强制我的应用程序使用通用名称 libpython2.6,而不是 libpython2.6.so.1.0?

我使用了这么小的一组 python API,我认为我应该安全地链接到库的更通用的版本名称。

最佳答案

看看``3.1.1。 http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html 中的共享库名称 '' ,这可能有助于您了解共享库的命名方法。

Every shared library has a special name called the soname''. 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 (as a special
exception, the lowest-level C
libraries don't start with
lib''). A fully-qualified soname includes as a prefix the directory it's in; on a working system a fully-qualified soname is simply a symbolic link to the shared library's ``real name''.

Every shared library also has a ``real name'', which is the filename containing the actual library code. The real name adds to the soname a period, a minor number, another period, and the release number. The last period and release number are optional. The minor number and release number support configuration control by letting you know exactly what version(s) of the library are installed. Note that these numbers might not be the same as the numbers used to describe the library in documentation, although that does make things easier.

In addition, there's the name that the compiler uses when requesting a library, (I'll call it the ``linker name''), which is simply the soname without any version number.

关于linux - 链接符号链接(symbolic link)而不是soname,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4561871/

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