Score:0

PostGIS has unmet libgdal20 dependency; manual compiling fails (18.04 LTS)

vn flag

I am trying to install PostGIS on top of PostgreSQL 13. I have already quite a GIS ecosystem in place, and run GDAL 3.0.4.

> dpkg -l | grep gdal

ii  gdal-bin                                   3.0.4+dfsg-1~bionic0
ii  gdal-data                                  3.0.4+dfsg-1~bionic0
ii  libgdal-dev                                3.0.4+dfsg-1~bionic0
ii  libgdal26                                  3.0.4+dfsg-1~bionic0
ii  python3-gdal                               3.0.4+dfsg-1~bionic0


> dzdo apt-get install postgis postgresql-13-postgis-3

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgis : Depends: libgdal20 (>= 2.0.1) but it is not going to be installed
 postgresql-13-postgis-3 : Depends: libgdal20 (>= 2.0.1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Odd given that PostGIS is advertised to work best with GDAL 3... but fine, I'll compile it myself.

> wget https://download.osgeo.org/postgis/source/postgis-3.1.4.tar.gz
> tar xf postgis-3.1.4.tar.gz
> cd postgis-3.1.4
> ./configure --without-protobuf
> make && dzdo make uninstall && dzdo make install

make is failing when building elements related to raster2pgsql:

make[2]: Entering directory '/home/USER/postgis-3.1.4/raster/loader'
/bin/bash ../../libtool --mode=link gcc -std=gnu99 -g -O2 -fno-math-errno -fno-signed-zeros  -fPIC -DPIC -I../rt_core -I../../liblwgeom  -I/usr/include/gdal -I/home/USER/anaconda3/include   ../rt_core/librtcore.a raster2pgsql.o -lm -static ../../liblwgeom/liblwgeom.la -L/usr/lib -lgdal  -L/home/USER/anaconda3/lib -lgeos_c  -lc -o raster2pgsql
libtool: link: gcc -std=gnu99 -g -O2 -fno-math-errno -fno-signed-zeros -fPIC -DPIC -I../rt_core -I../../liblwgeom -I/usr/include/gdal -I/home/USER/anaconda3/include raster2pgsql.o -o raster2pgsql  ../rt_core/librtcore.a ../../liblwgeom/.libs/liblwgeom.a -lm -L/home/USER/anaconda3/lib -lproj -ljson-c -L/usr/lib -lgdal -lgeos_c -lc
//usr/lib/x86_64-linux-gnu/libgeotiff.so.5: undefined reference to `_TIFFmemcpy@LIBTIFF_4.0'
/usr/lib/libgdal.so: undefined reference to `TIFFReadDirectory@LIBTIFF_4.0'
/usr/lib/libgdal.so: undefined reference to `TIFFClientdata@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libgeotiff.so.5: undefined reference to `_TIFFrealloc@LIBTIFF_4.0'
//usr/lib/x86_64-linux-gnu/libgeotiff.so.5: undefined reference to `_TIFFmemset@LIBTIFF_4.0'
/usr/lib/libgdal.so: undefined reference to `TIFFLastDirectory@LIBTIFF_4.0'

(...) many other lines with the same reference to @LIBTIFF_4.0

collect2: error: ld returned 1 exit status
Makefile:84: recipe for target 'raster2pgsql' failed
make[2]: *** [raster2pgsql] Error 1
make[2]: Leaving directory '/home/USER/postgis-3.1.4/raster/loader'
Makefile:35: recipe for target 'rtloader' failed
make[1]: *** [rtloader] Error 2
make[1]: Leaving directory '/home/USER/postgis-3.1.4/raster'
GNUmakefile:22: recipe for target 'all' failed
make: *** [all] Error 1

The error suggest some missing libtiff4. However, when trying to install it:

> dzdo apt-get install libtiff4
E: Unable to locate package libtiff4

> dzdo apt-get install libtiff4-dev
Package libtiff4-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
  libtiff5-dev:i386 libtiff5-dev
E: Package 'libtiff4-dev' has no installation candidate

> dzdo apt-get install libtiff5-dev
libtiff5-dev is already the newest version (4.0.9-5).

libtiff seems to be installed, in its version 5 though. When examining the possibilities to install libgdal20 with aptitude, the proposed solutions will remove a lot of the GIS packages I am using, so this is not really an option. I am not sure how to proceed.. any help is appreciated!

N0rbert avatar
zw flag
What was wrong with PostGIS 2.4.3 from [official repository](https://packages.ubuntu.com/bionic/postgis)?
M2FKXY avatar
vn flag
It requires libgdal20, which is conflicting with libgdal26 that is installed on my machine. Downgrading GDAL or making a double install would break or require me to remove a lot of other packages that I run, according to what aptitude proposes me.
Score:0
pe flag

I had encountered similar issues when compiling PostGIS from source (but under Ubuntu 20.04). My solution for solving the linking problem (for a different package) is described in the GIS.SE answer here.

It seems that the Makefile in PostGIS-3.1.0+ did not include the link options for some custom packages, in my case geos:

The problem is fixed by editing loader/Makefile and then appending the following GEOS link options

-L/opt/geos/lib -lgeos

to line 25 that looks like:

CFLAGS= -I ../liblwgeom -I/opt/geos/include ...

If your issue is the same, then adding link options in the appropriate Makefile (immediately after the ./configure ) may solve the problem.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.