Software & AppsOperating SystemLinux

How To fix “error while loading shared libraries: libpng12.so.0” in Ubuntu?

Ubuntu 14

If you’re an Ubuntu user, you might have come across the error “error while loading shared libraries: libpng12.so.0”. This error occurs when the system is unable to find the required library, in this case, libpng12.so.0. This library is not available in the default Ubuntu 16.10 repositories and later versions. This article will guide you through several solutions to fix this error.

Understanding the Error

The libpng12.so.0 is a shared library file. Shared libraries are collections of programming functions that can be used by multiple programs simultaneously. They help in saving memory and allow easier management of code updates. The error message indicates that the system is unable to locate this library file.

Solution 1: Download and Install the libpng12 Package

The first solution involves downloading the libpng12 package from the Ubuntu 16.04 repository and installing it manually. Here are the steps:

  1. Download the libpng12 package: Use the following links to download the package based on your system architecture:
  2. Open a terminal: You can do this by pressing Ctrl + Alt + T.
  3. Navigate to the directory where the downloaded package is located. You can use the cd command to change directories. For example, if the package is in the Downloads directory, use the command cd Downloads.
  4. Install the libpng12 package: Use the following command to install the package:
    sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb
    The sudo command is used to execute the command with root privileges. dpkg -i is used to install a package, and libpng12-0_1.2.54-1ubuntu1.1_amd64.deb is the name of the package. Replace this with the actual package name if it’s different.

Solution 2: Use the Linux Uprising PPA Repository

The second solution involves adding the Linux Uprising PPA repository, which provides a repackaged libpng12 package for Ubuntu 19.04 and later versions. Here are the steps:

  1. Add the Linux Uprising PPA repository: Use the following commands to add the repository and update the package list:
    sudo add-apt-repository ppa:linuxuprising/libpng12
    sudo apt update
    The add-apt-repository command is used to add a repository. ppa:linuxuprising/libpng12 is the PPA repository that contains the libpng12 package. The apt update command is used to update the package list.
  2. Install the libpng12 package: Use the following command to install the package:
    sudo apt install libpng12-0
    The apt install command is used to install a package, and libpng12-0 is the name of the package.

Solution 3: Create Symbolic Links to the libpng16 Library

The third solution involves creating symbolic links to the libpng16 library, which is available in Ubuntu 16.10. However, this may cause some warnings. Here are the steps:

  1. Create symbolic links: Use the following command to create symbolic links:
    sudo ln -s -T /usr/lib/x86_64-linux-gnu/libpng16.so /usr/lib/x86_64-linux-gnu/libpng12.so.0
    The ln -s -T command is used to create symbolic links. /usr/lib/x86_64-linux-gnu/libpng16.so is the source file, and /usr/lib/x86_64-linux-gnu/libpng12.so.0 is the target file.

Please choose the solution that best suits your situation and proceed with caution. Always remember to keep your system updated and backup your data regularly to prevent such errors.

Why am I getting the “error while loading shared libraries: libpng12.so.0” in Ubuntu?

The error occurs when the system is unable to find the required library file libpng12.so.0, which is not available in the default Ubuntu 16.10 repositories and later versions.

How can I fix the “error while loading shared libraries: libpng12.so.0” in Ubuntu?

There are several solutions to fix this error. You can either download and install the libpng12 package manually, use the Linux Uprising PPA repository to install the package, or create symbolic links to the libpng16 library.

How do I download and install the libpng12 package manually?

To download and install the libpng12 package manually, you need to download the package from the Ubuntu 16.04 repository based on your system architecture (64-bit or 32-bit). Then, open a terminal, navigate to the directory where the package is located, and use the command "sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb" to install the package.

Can I use the Linux Uprising PPA repository to fix the error?

Yes, you can. By adding the Linux Uprising PPA repository and updating the package list, you can install the repackaged libpng12 package for Ubuntu 19.04 and later versions using the command "sudo apt install libpng12-0".

Is creating symbolic links a recommended solution?

Creating symbolic links to the libpng16 library can be a workaround solution, but it may cause warnings. It is not the recommended approach, but it can be used if the other solutions are not applicable.

Which solution should I choose to fix the error?

It depends on your specific situation. If you are comfortable with manual installation, downloading and installing the libpng12 package manually can be a good option. If you prefer using a repository, adding the Linux Uprising PPA repository and installing the package is a viable solution. However, always proceed with caution and consider the potential risks involved.

How can I prevent such errors in the future?

To prevent such errors, it is important to keep your system updated and regularly install updates and security patches. Additionally, backing up your important data regularly can help in case any unexpected errors occur.

Leave a Comment

Your email address will not be published. Required fields are marked *