error while loading shared libraries: libpng12.so.0

you can either

install the supplied .deb file available from

https://packages.ubuntu.com/xenial/amd64/libpng12-0/download

http://security.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb

sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1_amd64.deb

or compile and install :

download source code https://packages.ubuntu.com/xenial/libpng12-0

wget http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng_1.2.54.orig.tar.xz

tar xvf  libpng_1.2.54.orig.tar.xz 

cd libpng-1.2.54
./autogen.sh
./configure
make -j8 
sudo make install

then update the links with:

sudo ldconfig

prior to any of this assure you machine has these preliminary packages installed ... baseline for any dev kit

sudo apt-get update
sudo apt-get upgrade 
sudo apt-get install libtool autoconf build-essential pkg-config automake tcsh

good news is freesurfer 7 on Ubuntu 20.04 runs fine out of the box


The software you are trying to run requires version 12 of libpng, which is no longer available in Ubuntu 16.10+. The best thing to do would be to install Ubuntu 16.04, or maybe let the developers of the software know about this problem so they can provide a version compatible with Ubuntu 16.10.


Download the shared library from https://packages.ubuntu.com/xenial/amd64/libpng12-0/download and then run sudo dpkg -i