Ubuntu 18.04.5 LTS 源码编译安装最新版gdal

1. ubuntu 安装 cmake-3.20

apt-get install wget
wget https://github.com/Kitware/CMake/releases/download/v3.20.2/cmake-3.20.2.tar.gz
tar zxvf cmake-3.20.2.tar.gz
apt-get install libssl-dev
./configure
make
make install

vim ~/.bashrc
export PATH=/usr/local/bin:$PATH

source ~/.bashrc

cmake --version

2. ubuntu 安装 proj.4

git clone https://github.com/OSGeo/proj.4.git /opt/proj.4
cd /opt/proj.4/
mkdir build/ && cd build/
安装依赖库
apt-get install libssl-dev
apt-get install sqlite3
apt-get install libsqlite3-dev
apt-get install libtiff-dev
apt-get install libcurl4-openssl-dev
apt-get install build-essential

#使用cmake生成Makefile,指定安装路径和生成库类型为静态库
cmake -DCMAKE_INSTALL_PREFIX=./install -DBUILD_LIBPROJ_SHARED=OFF …
#编译
make
#安装,安装的目录是之前指定的目录,就是当前目录下的install目录
make install
安装完成之后进入install目录,可以看到对应的头文件和库文件。

root@97a74eddb0a5:/opt/proj.4/build/install/lib# cp libproj.so.22.0.0 libinternalproj.so.22.0.0
root@97a74eddb0a5:/opt/proj.4/build/install/lib# ln -s libinternalproj.so.22.0.0 libinternalproj.so
root@97a74eddb0a5:/opt/proj.4/build/install/lib# ln -s libinternalproj.so.22.0.0 libinternalproj.so.22
root@97a74eddb0a5:/opt/proj.4/build/install/lib# apt-get install patchelf
#这一步应该不需要了
###root@97a74eddb0a5:/opt/proj.4/build/install/lib# patchelf --set-soname libinternalproj.so libinternalproj.so

在etc/ld.so.conf.d 文件夹中创建文件 proj6.conf
写入/opt/proj.4/build/install/lib
sudo ldconfig

3. 安装gdal

git clone https://github.com/OSGeo/gdal
#./configure --with-proj=/opt/proj.4/build/install --without-libtool
apt-get install -y pkg-config
#Configure gdal from /gdal using ./configure --with-threads --with-pg=YES --disable-static and verify that it prints PostgreSQL=yes
./configure --with-proj=/opt/proj.4/build/install --with-threads --with-pg --disable-static
export LD_LIBRARY_PATH=/opt/proj.4/build/install/lib:$LD_LIBRARY_PATH
make -j4
make install
gdal-config --version

在/etc/ld.so.conf.d 文件夹中创建文件 libgdal.conf
写入/home/ubuntu/Software/gdal/gdal/.libs

修改 ~/.bashrc

export PATH=/root/Software/gdal/gdal/apps:/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/opt/proj.4/build/install/lib:/usr/local/lib:$LD_LIBRARY_PATH

sudo ldconfig

#Verify postgresql driver persence by “ogrinfo --formats | grep PostgreSQL” which should print:
PostgreSQL -vector- (rw+): PostgreSQL/PostGIS
PGDUMP -vector- (w+v): PostgreSQL SQL dump

你可能感兴趣的:(postgres,gdal)