Question

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.

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) ?

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 ?

Thanks for help.

Best regards, Vincent.

Was it helpful?

Solution

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]

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top