下面所有步驟均在root用戶下執(zhí)行
所用軟件如下:
proj-4.9.3.tar.gz
geos-3.6.2.tar.gz
jpegsrc.v9b.tar.gz
hdf-4.2.13.tar.gz
hdf5-1.10.1.tar.gz
netcdf-4.4.1.tar.gz
gdal-2.4.0.tar.gz
下載地址:鏈接:https://pan.baidu.com/s/1NxCT17mwGO5Mhovke-p_iQ
提取碼:udqn
1、準(zhǔn)備環(huán)境
搭建私有yum源或者聯(lián)網(wǎng)的方式安裝
yum -y groupinstall "Development tools"
yum -y install zlib-devel
2、安裝geos
tar -xjf geos-3.6.2.tar.bz2
cd geos-3.6.2
./configure
make
make install
3蜂挪、安裝proj
tar -xjf proj-4.9.3.tar.gz
cd proj-4.9.3
./configure
make
make install
4猖闪、安裝jpegsrc
tar -zxf jpegsrc.v9b.tar.gz
cd jpeg-9b/
./configure --prefix=/opt/jpeg
make
make install
5、安裝hdf5
tar -zxf hdf5-1.10.1.tar.gz
cd hdf5-1.10.1
export F9X=ifort
./configure --prefix=/opt/hdf5 --with-hdf4=/opt/hdf4 --with-jpeg=/opt/jpeg --enable-java --enable-cxx
make
make install
6载慈、安裝hdf
tar -zxf hdf-4.2.13.tar.gz
cd hdf-4.2.13
./configure --prefix=/opt/hdf4 --enable-netcdf --enable-jpeg --with-jpeg=/opt/jpeg --enable-hdf5 --with-hdf5=/opt/hdf5 --enable-shared --disable-fortran --enable-java
make
make install
7慨绳、安裝netcdf
tar -zxf netcdf-4.4.1.tar.gz
cd netcdf-4.4.1
CPPFLAGS="-l/opt/hdf4/include -l/opt/hdf5/include -l/opt/jpeg/include"
LDFLAGS="-l/opt/hdf4/lib -l/opt/hdf5/lib -l/opt/jpeg/lib"
./configure --prefix=/opt/netcdf --enable-hdf5 --with-hdf5=/opt/hdf5 --enable-hdf4 --with-hdf4=/opt/hdf4 --enable-jpeg --with-jpeg=/opt/jpeg --disable-netcdf-4
make
make install
8阅爽、安裝gdal
tar -zxf gdal-2.4.0.tar.gz
cd gdal-2.4.0
./configure --prefix=/opt/gdal --enable-netcdf --with-netcdf=/opt/netcdf --enable-hdf5 --with-hdf5=/opt/hdf5 --enable-hdf4 --with-hdf4=/opt/hdf4
make
make install
9挟伙、修改配置文件
vi /etc/profile
export PATH=${PATH}:/opt/hdf4/include:/opt/hdf4/bin:/opt/hdf5/include:/opt/hdf5/bin:/opt/netcdf/include:/opt/netcdf/bin:/opt/gdal/include:/opt/gdal/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/hdf4/lib:/opt/hdf5/lib:/opt/netcdf/lib:/opt/gdal/lib
source /etc/profile
驗(yàn)證是否安裝成功
gdalinfo
10楼雹、編譯Java版gdal
進(jìn)入<gdal-dir>\swig\java修改java.opt文件,指定jdk的路徑尖阔,<gdal-dir>為gdal文件夾贮缅。內(nèi)容如下:
JAVA_HOME = /opt/jdk1.8 //修改成自己的JAVA_HOME路徑
JAVADOC=$(JAVA_HOME)/bin/javadoc
JAVAC=$(JAVA_HOME)/bin/javac
JAVA=$(JAVA_HOME)/bin/java
JAR=$(JAVA_HOME)/bin/jar
JAVA_INCLUDE=-I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
11、編譯動(dòng)態(tài)鏈接庫(需要ant環(huán)境)
進(jìn)入進(jìn)入<gdal-dir>\swig\java
make
將編譯好的動(dòng)態(tài)庫 libgdalalljni.so
放到需要使用它的地方(一般放在 LD_LIBRARY_PATH的路徑下面)