How to install BPG (Better Portable Graphics) on Linux Mint 17?
libbpg
depends on version 1.6 of the PNG library, which you cannot install with apt-get
on Linux Mint 17. This library is incompatible with libpng12
and needs to be installed from source (I used version 1.6.16)
The additional complication is that if you install PNG 1.6 the make
of libbpg
still uses libpng12-dev
even if you configure PNG 1.6 with configure --prefix=/usr
. And you cannot just deinstall libpng12-dev
as libsdl-image1.2-dev
and libsdl1.2-dev
depend on it, and those are needed for compiling libbpg
as well.
You could probably also download and compile the libsdl-image
and libsdl1
sources and not install their -dev
packages. I did not follow that route, I just temporarily removed the files (not the package) from libpng12-dev
and reinstalled them after I was done (you should be able to copy and paste this on Linux Mint 17):¹
# install dev packages needed
sudo apt-get install -y libsdl-image1.2-dev libsdl1.2-dev libjpeg8-dev
#### temporarily remove the files from the libpng12 package
# this gives error messages on the directories (that cannot be removed this
# way, which can be ignored.
sudo rm $(dpkg -L libpng12-dev)
# download, configure, make and make install PNG 1.6
wget -O libpng-1.6.16.tar.xz 'http://downloads.sourceforge.net/project/libpng/libpng16/1.6.16/libpng-1.6.16.tar.xz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flibpng%2Ffiles%2Flibpng16%2F1.6.16%2F&ts=1424607004&use_mirror=garr'
tar xf libpng-1.6.16.tar.xz
pushd libpng-1.6.16
./configure --prefix=/usr
make -j
sudo make install
popd
# download, make and make install BPG
wget http://bellard.org/bpg/libbpg-0.9.5.tar.gz
tar xf libbpg-0.9.5.tar.gz
pushd libbpg-0.9.5
make -j
sudo make install
popd
# reinstall libpng12-dev
sudo apt-get install --reinstall libpng12-dev
Of course it would be more appropriate to install PNG 1.6 in parallel to libpng12-dev
and adapt the sources of libbpg
, but since you don't recompile the BPG library on a regular basis, IMO this kludge is acceptable.
¹ You could also try and build libpng16-dev, but installing that might just remove the -dev
packages depending on libpng12-dev
, I did not try that.
It's better not to change the officialy installed package libpng12-dev but rather to indicate in the Makefile from libbpg where to find libpng 1.6
So I modify the Anthon's solution :
# install dev packages needed
sudo apt-get install -y libsdl-image1.2-dev libsdl1.2-dev libjpeg8-dev
# download, configure, make and make install PNG 1.6 (You coul find a newer version like 1.16.18 for me)
wget -O libpng-1.6.16.tar.xz 'http://downloads.sourceforge.net/project/libpng/libpng16/1.6.16/libpng-1.6.16.tar.xz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flibpng%2Ffiles%2Flibpng16%2F1.6.16%2F&ts=1424607004&use_mirror=garr'
tar xf libpng-1.6.16.tar.xz
pushd libpng-1.6.16
./configure
make -j
sudo make install
#### The installation will take place in /usr/local by default and it's ok !
popd
# download, make and make install BPG
wget http://bellard.org/bpg/libbpg-0.9.5.tar.gz
tar xf libbpg-0.9.5.tar.gz
pushd libbpg-0.9.5
#### edit Makefile and insert the two following directive :
# "CFLAGS+=-I/usr/local/include" after the line CFLAGS+=-I.
# "LDFLAGS+=-L /usr/local/lib" before the line CFLAGS+=-g
make -j
sudo make install
popd
That's all folks !
The other answers on here are great, but I wanted to create a completely automated installation script.
#!/bin/bash
sudo apt-get install -y cmake yasm libjpeg-dev libsdl-image1.2-dev libsdl1.2-dev
pushd /tmp
wget -O libpng-1.6.21.tar.xz "https://downloads.sourceforge.net/project/libpng/libpng16/older-releases/1.6.21/libpng-1.6.21.tar.gz?ts=$(date +%s)"
tar xf libpng-1.6.21.tar.xz
pushd libpng-1.6.21
./configure
make -j
sudo make install
popd
git clone "https://github.com/mirrorer/libbpg"
pushd libbpg
patch <<EOF
--- Makefile 2016-02-03 11:43:37.883142427 -0500
+++ Makefile 2016-02-03 11:44:20.867143492 -0500
@@ -41,6 +41,7 @@
CFLAGS:=-Os -Wall -MMD -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -fomit-frame-pointer
CFLAGS+=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_REENTRANT
CFLAGS+=-I.
+CFLAGS+=-I/usr/local/include
CFLAGS+=-DCONFIG_BPG_VERSION=\"\$(shell cat VERSION)\"
ifdef USE_JCTVC_HIGH_BIT_DEPTH
CFLAGS+=-DRExt__HIGH_BIT_DEPTH_SUPPORT
@@ -59,6 +60,7 @@
else
LDFLAGS+=-Wl,--gc-sections
endif
+LDFLAGS+=-L /usr/local/lib
CFLAGS+=-g
CXXFLAGS=\$(CFLAGS)
EOF
make -j
sudo make install
popd
popd
sudo ldconfig # Required for bpgenc to find libpng16.