I have a Debian package for a shared library. Lets assume the lib is called threadx. And I have the version 0.0.1 installed. So this package contains:

/lib/i386-linux-gnu/libthreadx.so.0 # symlink to libthreadx.so.0.0.1

If I want to upgrade now to 0.0.2 the package will contain:

/lib/i386-linux-gnu/libthreadx.so.0 # symlink to libthreadx.so.0.0.2

Which conflicts because /lib/i386-linux-gnu/libthreadx.so.0 is the same file. The error message is

dpkg: error processing archive /tmp/apt-dpkg-install-SwpeYD/01-libthreadx0.0.2_0.0.2_i386.deb (--unpack):
 trying to overwrite '/lib/i386-linux-gnu/libthreadx.so.0', which is also in package libthreadx0.0.1:i386 0.0.1

I want to be able to install both packages (libthreadx0.0.1 and libthreadx0.0.2) in parallel, and have the symlink point to the latest library.

And I am unable to find actual advice how to configure/package this that this works. There is this thread talking about it but not telling any details:

Actually, you can install multiple versions of a shared library if it's done properly.

Why can't I install multiple versions of a shared library?

And the debian manual is also very obscure to me so either the information on how to do this is not there or i don't understand it. https://www.debian.org/doc/debian-policy/ch-sharedlibs.html


1 Answer 1


The problem comes from the presence of the full version in the package name: libthreadx0.0.2 and libthreadx0.0.1. When you install the former, dpkg doesn’t consider it to be an upgrade to the latter, but a new package installed alongside it. As a result, dpkg won’t handle “replaced” files for you automatically, you have to provide additional information to help it do so.

In theory, library package names are supposed to reflect the library’s soname, libthreadx.so.0 in this case; so the library package should be libthreadx0, with an appropriate version number after the underscore: libthreadx0_0.0.1-1_i386.deb, libthreadx0_0.0.2-1_i386.deb. But as you note, this doesn’t allow parallel installation.

Since you want to allow parallel installation, you have to allow packages containing later versions of the library to replace the symlink in earlier packages: you can do this by adding a Replaces stanza in the package’s control file, e.g. in this instance, in libthreadx0.0.2’s control file,

Replaces: libthreadx0.0.1

This doesn’t mean that libthreadx0.0.2 entirely replaces libthreadx0.0.1, but it allows it to provide conflicting files. When libthreadx0.0.2 is installed, its symlink will replace libthreadx0.0.1’s.

Technically, since this changes the symlink, it “breaks” (in dpkg terminology) the libthreadx0.0.1 package — or rather, it breaks packages relying on libthreadx0.0.1, since they will no longer find the right library through the symlink formerly provided by libthreadx0.0.1. This would typically be declared using a Breaks stanza as well, but this isn’t appropriate here since you want to keep libthreadx0.0.1.

This will also result in a broken setup if the user installs libthreadx0.0.1, installs libthreadx0.0.2, then removes libthreadx0.0.2, expecting libthreadx0.0.1 to be used again: the symlink won’t be restored.

The fact that your soname is the same in both libraries suggests that they aren’t really usable in parallel in the first place, but that’s a concern for another discussion.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .