Installing Libpng on Ubuntu Linux

This short tutorial shows you how to install libpng on Ubuntu Linux Server. The process is very simple. For this tutorial, I'll be installing libpng version 1.5.4. Linux kernel used is 2.6.21.7-2.fc8xen. I have used an Amazon EC2 Ubuntu instance. GCC version number is 4.1.3. Your configuration may be different from mine but the installation steps below should work fine for most configurations with little or no change at all (including other Linux distributions and even unixes e.g. MacOS x).

Libpng:

According to libpng.sourceforge.net,

"This is an open source project to develop and maintain the reference library for use in applications that create and manipulate PNG (Portable Network Graphics) raster image files."

Before starting, please check to see if there is a latest version available to download. Visit http://libpng.sourceforge.net/ to find out about available versions. IMPORTANT: See "Configuring Ubuntu Linux After Installation" to install the development tools required to compile and install libpng from source code.

Steps to download, compile, and install are as follows. Note: Replace 1.5.4 with your version number:

  • Install zlib development package:

    Without sudo,

    apt-get install zlib1g-dev

    With sudo,

    sudo apt-get install zlib1g-dev
    Run command above to install the zlib development package.
  • Downloading Libpng:

    Run the command below,
    wget http://prdownloads.sourceforge.net/libpng/libpng-1.5.4.tar.gz?download

    NOTE: If the download link (above) does not work, go to http://downloads.sourceforge.net/libpng/ to find a new link.

  • Extracting files from the downloaded package:

    tar xzf libpng-1.5.4.tar.gz

    Now, enter the directory where the package is extracted.

    cd libpng-1.5.4

  • Configuring Libpng Library:

    ./configure --prefix=/usr/local/libpng

    Replace "/usr/local/libpng" above with the directory path where you want to copy the files and folders. Note: check for any error message.
  • Compiling Libpng:

    make

    Note: check for any error messages.

  • Installing libpng:

    As root (for privileges on destination directory), run the following.

    With sudo,

    sudo make install

    Without sudo,

    make install

    Note: check for any error messages.

That’s it. Library has bee successfully installed.

Did this tutorial help a little? How about buy me a cup of coffee?

Buy me a coffee at ko-fi.com

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.

IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.

Comments (write a comment):

In order to be able to create animated png files in the GIMP I need an updated libpng in Ubuntu11.04.

I've tried the above described process but have not been able to get past the downloading part.
I used the following command:
wget http://sourceforge.net/projects/apng/files/libpng/libpng15/libpng-1.5.4-apng.patch.gz/download

After this I used the command:
tar -xvzt libpng-1.5.4-apng.patch.gz but with no result. I'm not able to unzip it and thus unable to follow the rest of the guide.

I'm stuck. Could anyone please help me? Posted by: Newbuntuman on Jul 10, 2011

@Newbuntuman: I have updated the tutorial for the latest release for you. Basically, the steps are almost the same with no major changes. Posted by: Shahryar on Jul 11, 2011

leave a comment on tutorial leave a comment