问题描述
几个月前,我建立了使用的libxml2作为共享库,在Debian一个C软件。
我创建了一个.deb文件进行安装的软件,和Ubuntu用户可以使它运行。
A few months ago, I built a C software that used libxml2 as a shared library, on a debian.I created a .deb file for installation of the software, and Ubuntu users could make it run.
今天,Ubuntu的最新版本的libxml2有一个更大的版本。所以,现在,该软件不能运行,它要求的libxml2的previous版本,并使其工作正在建设的软件,而在libxml2的新版连接的唯一途径。
Today, the latest version of Ubuntu has a greater version of libxml2. So now, the software doesn't run, it asks for a previous version of libxml2 and the only way to make it work is building the software while linking on the new version of libxml2.
所以我的问题是,是否有可能不需要一个特定版本(取软件无法在某些版本工作的风险)对共享库链接?
So my question is, is it possible to link against a shared library without requiring a specific version (taking the risk the software could not work on some version) ?
如果不是的话,那么什么是一个共享库链接,如果你不能在任何Linux分发部署软件的真正优势在哪里?
If it's not, then what is the real advantage of linking with a shared library if you can't deploy your software on any Linux distribution ?
感谢您的帮助。
最好的问候,
文森特。
Best regards,Vincent.
推荐答案
大多数共享库将有一个嵌入的 SONAME
。这 SONAME
用于指示二进制兼容性。例如,libxml2.so.2.7.8已嵌入libxml2.so.2的 SONAME
:
Most shared libraries will have an embedded SONAME
. This SONAME
is used to indicate binary compatibility. For example, libxml2.so.2.7.8 has an embedded SONAME
of libxml2.so.2:
readelf -Wa libxml2.so.2.7.8 | grep SONAME
0x000000000000000e (SONAME) Library soname: [libxml2.so.2]
如果libxml2.so.2.7.9出来了,它可能会仍然二进制兼容v2.7.8,并且仍然有一个 SONAME
libxml2.so的。 2,你的应用程序会工作得很好。只有当一个变化是引入了爆发二进制兼容性会在 SONAME
得到增加,打破你的申请。
If libxml2.so.2.7.9 came out, it would likely still be binary compatible with v2.7.8, and would still have an SONAME
of libxml2.so.2 and your application would work just fine. Only when a change was introduced that broke binary compatibility would the SONAME
get incremented, breaking your application.
如果你想创建一个包,将在所有发行版自动工作,一种方法是提供自己的libxml2的版本,然后修改 LD_LIBRARY_PATH
这样你的版本自动被加载。
If you want to create a package that will automatically work on all distributions, one approach is to deliver your own version of libxml2, then modify the LD_LIBRARY_PATH
such that your version automatically gets loaded.
这篇关于与没有版本的共享库链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!