error while loading shared libraries: libpng12.so.0

I am trying to install FreeSurfer: ftp://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz

I am following these steps to install FreeSurfer: https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall

When I run following commands:

freeview -v \
    bert/mri/T1.mgz \
    bert/mri/wm.mgz \
    bert/mri/brainmask.mgz \
    bert/mri/aseg.mgz:colormap=lut:opacity=0.2 \
    -f \
    bert/surf/lh.white:edgecolor=blue \
    bert/surf/lh.pial:edgecolor=red \
    bert/surf/rh.white:edgecolor=blue \
    bert/surf/rh.pial:edgecolor=red

I get this error:

freeview.bin: error while loading shared libraries: libpng12.so.0: cannot open shared object file: No such file or directory

And when I am trying to install this package:

sudo apt-get install libpng12.so.0

I am getting this error:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libpng12.0-0:i386
E: Couldn't find any package by glob 'libpng12.0-0'
E: Couldn't find any package by regex 'libpng12.0-0'

I am totally new to Linux, please help!


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.