Search code examples
shared-librariesgnuautotoolslibtool

installed shared library version number does not match LT_VERSION_INFO


The libtool versioning number of a shared library is set in configure.ac via LT_VERSION_INFO="lt_current:lt_revision:lt_age" but when I set it to 0:1:0 make install installs the lib..so.0.0.1, and when I set it to 3:2:1 it installs lib..so.2.1.2. This does not seem right. If it is, can someone please explain what's going on? Otherwise, what could be wrong? The libtool version is 2.4.2.

I am familiar with the fact libtool versions differ from release version. That is not the problem here.


Solution

  • You might find this explanation and example useful; there are others similar to it on the net, but this one has a practical workflow at the end (as does the documentation for libtool). So, with this in mind, let's run through your examples for -version-info:

    0:1:0

    Says to libtool: for API 0, I have made one change to the source files, and no backward-compatible additions to the API.

    Now libtool abstracts the shared library building process away from the real platform tools so that you can just drop an autotools built tarball on a system and type ./configure && make && make install and have a reasonable chance of working software at the end of that build. Some platforms will care about the contents of -version-info (e.g. Linux, which I'm kind of assuming that you are building for, so you'll see libfoo.so.0.0.1), and others will not (e.g. Android, so you'll see libfoo.so), and there's others that somewhat care. Since libtool has to span different platforms, they had to come up with a scheme that would allow them to compute the right values on all their target platforms. And that's why the numbering is somewhat unintuitive.

    So on Linux, "0:1:0" translates to libfoo.so.0.0.1 since the linker uses a major.minor.patchlevel scheme for differentiating libraries. On another OS, this may be different, or nonexistent.

    3:2:1

    Says to libtool: for API 2, I have made one backward-compatible change to the API, and two subsequent source changes. You get the API number by (current - age) = (3 - 1) = 2. You know that you have subsequent changes since revision gets reset to 0 on any API change (and current gets incremented). And so on Linux that means you get libfoo.so.2.1.2.