Ubuntu – How to correctly install libpng12-0 on the Ubuntu 19.10


For ScreenLets application I need to install libpng12-0 package on the Ubuntu 19.10 system.

I know that it is available only for Ubuntu 16.04 LTS.

So I have decided to download this package manually and install it by hand.

On previous Ubuntu versions (such as 18.04 LTS) this trick ends with success, but here on 19.10 it fails in very strange way:

wget http://mirrors.kernel.org/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb
sudo apt-get install ./libpng12-0_1.2.54-1ubuntu1.1_amd64.deb

0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/116 kB of archives.
After this operation, 285 kB of additional disk space will be used.
Get:1 /home/user/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb libpng12-0 amd64 1.2.54-1ubuntu1.1 [116 kB]
Selecting previously unselected package libpng12-0:amd64.
(Reading database ... 212864 files and directories currently installed.)
Preparing to unpack .../libpng12-0_1.2.54-1ubuntu1.1_amd64.deb ...
Unpacking libpng12-0:amd64 (1.2.54-1ubuntu1.1) ...

dpkg: error processing archive /home/user/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb (--unpack):
 unable to install new version of '/lib/x86_64-linux-gnu/libpng12.so.0': No such file or directory
No apport report written because the error message indicates an issue on the local system
                                                                                         Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

What is wrong here? How can I get libpng12-0 installed on Ubuntu 19.10 system?

Note: the same happens on 19.04, but it is near EOL.

Best Answer

There is a PPA that has libpng12-0 for Ubuntu 21.04, 20.10, 20.04 LTS, 19.10 and 19.04: https://launchpad.net/~linuxuprising/+archive/ubuntu/libpng12.

You can either download the libpng12-0 deb from here or add the PPA:

sudo add-apt-repository ppa:linuxuprising/libpng12
sudo apt update
sudo apt install libpng12-0

The reason the old libpng12-0 doesn't work in Ubuntu 19.04 (and newer) is that with Ubuntu 19.04, the /lib directory is a symlink to /usr/lib (this was not the case with Ubuntu 18.04 and older), and this causes the libpng12-0 installation to fail, since this package tries to create a link from /lib/x86_64-linux-gnu/libpng12.so.0 to /usr/lib, which is already a symlink. So the libpng12-0 DEB had to be repacked to fix this issue and get it to install.

Source: Linux Uprising.