PostGIS 有未满足的 libgdal20 依赖性;手动编译失败(18.04 LTS)

PostGIS 有未满足的 libgdal20 依赖性;手动编译失败(18.04 LTS)

我正在尝试在 PostgreSQL 13 上安装 PostGIS。我已经建立了相当完善的 GIS 生态系统,并且运行 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.

奇怪的是,据称 PostGIS 最适合与 GDAL 3 配合使用...但没关系,我会自己编译它。

> 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构建与 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

该错误表明缺少一些libtiff4。但是,当尝试安装它时:

> 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).

libtifflibgdal20似乎已安装,但版本为 5。在检查使用进行安装的可能性时aptitude,建议的解决方案将删除我正在使用的许多 GIS 包,因此这实际上不是一个选择。我不确定如何继续。任何帮助都非常感谢!

答案1

我在从源代码编译 PostGIS 时遇到了类似的问题(但在 Ubuntu 20.04 下)。我解决链接问题(针对不同的包)的解决方案在GIS.SE 在此处回答

在我看来,PostGIS-3.1.0+ 中的 Makefile 似乎没有包含某些自定义包的链接选项geos

loader/Makefile通过编辑并附加以下 GEOS 链接选项可以修复此问题

-L/opt/geos/lib -lgeos

第 25 行如下所示:

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

如果您的问题相同,那么在适当的位置Makefile(紧接着./configure)添加链接选项可能会解决问题。

相关内容