jpeg2000dataset.cpp:40:10: fatal error:
Linux(centos8)系统安装编译GDAL 2.2.1
。。。安装中最坑的一个报错: jpeg2000dataset.cpp:35:10: fatal error: jasper/jasper.h
引言:
GDAL库是处理地理信息一个非常强大的库,我这边要用它做 cad 转 geojson 的工作。测试是在windows上进行的,然后现在需要部署到linux上,遇到了安装上的坎儿,记录一下。
linux系统:
[root@cumt gdal-2.2.1]# cat /proc/version
Linux version 4.18.0-193.el8.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)) #1 SMP Fri May 8 10:59:10 UTC 2020
GDAL安装:
1. 下载地址:
DownloadSource – GDAL (osgeo.org)
可以直接:
# cd /storage/software/gdal
# wget -c http://download.osgeo.org/gdal/2.2.1/gdal-2.2.1.tar.gz
2. 解压源码、进入解压包:
# tar xvf gdal-2.2.1.tar.gz
# cd gdal-2.2.1
3. 安装编译需要的库:
# yum install -y gcc make subversion gcc-c++ sqlite-devel libxml2-devel swig expat-devel libcurl-devel python36-devel
python36-devel 找不到的话 用:python-devel
4. 执行配置、编译、安装:
# ./configure
# make
# make install
在make编译这一步,我报了个错误:
jpeg2000dataset.cpp:35:10: fatal error: jasper/jasper.h: No such file or directory
jpeg2000dataset.cpp:35:10: fatal error: jasper/jasper.h: No such file or directory
#include <jasper/jasper.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
image.png
仔细看错误在于:找不到jasper...,是调用 “jpeg2000dataset.cpp”这个文件报的错
jasper是个什么玩意,我没去研究,最后在gdal官方上找到了对应的解释:
JPEG2000 – Implementation of the JPEG-2000 part 1 — GDAL documentation
image.png
废话不多说,直接下载jasper来安装:
下载jasper:http://download.osgeo.org/gdal/jasper-1.900.1.uuid.tar.gz
安装:参考官网
)
所有步骤,按顺序执行:
# cd /storage/software/JasPer
# wget http://download.osgeo.org/gdal/jasper-1.900.1.uuid.tar.gz
# tar xvf jasper-1.900.1.uuid.tar.gz
# cd jasper-1.900.1.uuid
# ./configure
# make
# make install
jasper安装完之后,重新执行步骤4(4. 执行配置、编译、安装:)
5. 等待编译完成,在bashrc文件中添加库链接:
# vi ~/.bashrc
在最后添加如下:
export PATH=$PATH:/usr/local/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
保存:
# :wq
应用:
# source ~/.bashrc
这步不执行会报错:报错:gdalinfo: error while loading shared libraries: libgdal.so.20: cannot open shared object file: No such file or directory
找不到共享库,意思就是在 bashrc 中添加的没生效。
解决:参考:https://zhidao.baidu.com/question/1929349307136401747.html
6.检验gdal是否安装成功:
# gdalinfo --version
image.png