编译

环境:

操作系统: Centos7:1806

编译器: GCC 7.3

CMake: 3.19

约定:

  1. 我们所有编译的软件都会安装到 /home/3rd_inst

  2. 系统已安装编译需要的必备工具

    • autoconf

    • automake

    • libtool

依赖库编译

名称

Centos(7.6)版本

openEuler(20.03)版本

操作

备注

libtiff-devel

4.0.3

4.1.0

yum install libtiff-devel

PROJ 依赖

libcurl-devel

7.29.0

7.71.1

yum install libcurl-devel

PROJ 依赖

gmp-devel

6.0.0

6.2.0

yum install gmp-devel

CGAL 依赖

mpfr-devel

3.1.1

4.1.0

yum install mpfr-devel

CGAL 依赖

boost-devel

1.53.0

1.73.0

yum install boost-devel

CGAL/SFCGAL 依赖

libuuid-devel

2.23.2

2.35.2

yum install libuuid-devel

JSON-C

0.11

0.15

yum install json-c-devel

LIBXML2

2.9.1

2.9.10

yum install libxml2-devel

SQLite3

3.39

3.39

编译

PROJ 依赖

PROJ

8.1.1

8.1.1

编译

GEOS

3.10.4

3.10.4

编译

GDAL

3.3.2

3.3.2

编译

CGAL

4.13.2

4.13.2

编译

SFCGAL

1.3.8

1.3.8

编译

PROTOBUF-CPP

3.16.0

编译

PROTOBUF-C 依赖

PROTOBUF-C

1.4.0

编译

SQLite3

  1. 下载源码

    wget https://www.sqlite.org/2022/sqlite-autoconf-3390400.tar.gz
    
  2. 解压软件包

    tar -xf sqlite-autoconf-3390400.tar.gz
    
  3. 修改源代码

    在后续编译 GDAL 时,会使用到 SQLite3 的一些特性,所以这里我们需要修改一下源代码,进入 sqlite3 目录,在 sqlite3.c 文件的第 25 行添加 #define SQLITE_ENABLE_COLUMN_METADATA 1,或者直接使用下面的命令修改

    sed -i '25 i #define SQLITE_ENABLE_COLUMN_METADATA 1' sqlite3.c
    
  4. 检查环境,生成编译脚本

    ./configure --prefix=/home/3rd_inst/sqlite3
    
  5. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/sqlite3 看到编译好的 SQLite3.

PROJ

  1. 下载源码

    wget http://download.osgeo.org/proj/proj-8.1.1.tar.gz
    
  2. 解压软件包

    tar -xf proj-8.1.1.tar.gz
    
  3. 导出环境变量

    Porj 编译需要使用 SQLite3 3.11 以上版本,因此这里我们使用我们刚刚编译的 SQLite3,首先将其 pkg-config 文件路径导出:

    export PKG_CONFIG_PATH=/home/3rd_inst/sqlite3/lib/pkgconfig:$PKG_CONFIG_PATH
    

    同时使用我们编译好的 sqlite3 程序:

    export PATH=/home/3rd_inst/sqlite3/bin/:$PATH
    
  4. 检查环境,生成编译脚本

    ./configure --prefix=/home/3rd_inst/proj
    
  5. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/proj 看到编译好的 Proj.

GEOS

  1. 下载源码

    wget https://download.osgeo.org/geos/geos-3.10.4.tar.bz2
    
  2. 解压软件包

    tar -xf geos-3.10.4.tar.bz2
    
  3. 检查环境,生成编译脚本

    cmake3 -DCMAKE_INSTALL_PREFIX=/home/3rd_inst/geos .
    
  4. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/geos 看到编译好的 GEOS.

GDAL

  1. 下载源码

    wget http://upload.osgeo.org/gdal/3.3.2/gdal-3.3.2.tar.gz
    
  2. 解压软件包

    tar -xf gdal-3.3.2.tar.gz
    
  3. 导出环境变量

    export LIBRARY_PATH=/home/3rd_inst/proj/lib/:$LIBRARY_PATH
    export CPATH=/home/3rd_inst/proj/include:$CPATH
    
  4. 检查环境,生成编译脚本

    ./configure --prefix=/home/3rd_inst/gdal
    
  5. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/gdal 看到编译好的 GDAL.

CGAL

  1. 下载源码

    wget https://github.com/CGAL/cgal/archive/refs/tags/releases/CGAL-4.13.2.tar.gz
    
  2. 解压软件包

    tar -xf CGAL-4.13.2.tar.gz
    
  3. 检查环境,生成编译脚本

    cmake3 -DCMAKE_INSTALL_PREFIX=/home/3rd_inst/cgal -DCMAKE_BUILD_TYPE=Release
    
  4. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/cgal 看到编译好的 CGAL.

SFCGAL

  1. 下载源码

    wget https://github.com/Oslandia/SFCGAL/archive/refs/tags/v1.3.8.tar.gz
    
  2. 解压软件包

    tar -xf v1.3.8.tar.gz
    
  3. 检查环境,生成编译脚本

    cmake3 -DCMAKE_INSTALL_PREFIX=/home/3rd_inst/sfcgal -DCMAKE_PREFIX_PATH=/home/3rd_inst/cgal/lib64/cmake/CGAL
    
  4. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/sfcgal 看到编译好的 SFCGAL.

JSON-C

  1. 下载源码

    wget https://github.com/json-c/json-c/archive/refs/tags/json-c-0.15-20200726.tar.gz
    
  2. 解压软件包

    tar -xf json-c-0.15-20200726.tar.gz
    
  3. 检查环境,生成编译脚本

    cmake3 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/3rd_inst/json-c
    
  4. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/json-c 看到编译好的 JSON-C.

LIBXML2

  1. 下载源码

    wget https://github.com/GNOME/libxml2/archive/refs/tags/v2.9.12.tar.gz
    
  2. 解压软件包

    tar -xf v2.9.12.tar.gz
    
  3. 检查环境,生成编译脚本

    sh autogen.sh --prefix=/home/3rd_inst/libxml2
    
  4. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/libxml2 看到编译好的 LIBXML2.

PROTOBUF-CPP

  1. 下载源码

    wget https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/protobuf-cpp-3.16.0.tar.gz
    
  2. 解压软件包

    tar -xf protobuf-cpp-3.16.0.tar.gz
    
  3. 检查环境,生成编译脚本

    ./configure --prefix=/home/3rd_inst/protobuf
    
  4. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/protobuf 看到编译好的 PROTOBUF-CPP.

PROTOBUF-C

  1. 下载源码

    wget https://github.com/protobuf-c/protobuf-c/releases/download/v1.4.0/protobuf-c-1.4.0.tar.gz
    
  2. 解压软件包

    tar -xf protobuf-c-1.4.0.tar.gz
    
  3. 导出环境变量

    这里我们指明刚刚安装的 Protobuf-cpp 的 pkg-config 文件路径

    export PKG_CONFIG_PATH=/home/3rd_inst/protobuf/lib/pkgconfig:$PKG_CONFIG_PATH
    
  4. 检查环境,生成编译脚本

    ./configure --prefix=/home/3rd_inst/protobuf-c
    
  5. 编译,安装

    make -j4 && make install
    

    编译完成后就可以在 /home/3rd_inst/protobuf-c 看到编译好的 PROTOBUF-C.

到此为止,所有的三方依赖库已经编译完成,这里我们新建一个 enable 文件,用于导出我们在后续会用到的环境变量

#!/bin/bash

PREFIX=/home/3rd_inst

export LIBRARY_PATH=${PREFIX}/sqlite3/lib:${PREFIX}/proj/lib:${PREFIX}/gdal/lib:${PREFIX}/protobuf/lib:${PREFIX}/protobuf-c/lib:${PREFIX}/libxml2/lib:${PREFIX}/geos/lib64:${PREFIX}/cgal/lib64:${PREFIX}/sfcgal/lib64:${PREFIX}/json-c/lib64:$LIBRARY_PATH

export LD_LIBRARY_PATH=${PREFIX}/sqlite3/lib:${PREFIX}/proj/lib:${PREFIX}/gdal/lib:${PREFIX}/protobuf/lib:${PREFIX}/protobuf-c/lib:${PREFIX}/libxml2/lib:${PREFIX}/geos/lib64:${PREFIX}/cgal/lib64:${PREFIX}/sfcgal/lib64:${PREFIX}/json-c/lib64:$LD_LIBRARY_PATH

export PKG_CONFIG_PATH=${PREFIX}/sqlite3/lib/pkgconfig:${PREFIX}/proj/lib/pkgconfig:${PREFIX}/geos/lib64/pkgconfig:${PREFIX}/gdal/lib/pkgconfig:${PREFIX}/sfcgal/lib64/pkgconfig:${PREFIX}/protobuf/lib/pkgconfig:${PREFIX}/protobuf-c/lib/pkgconfig:${PREFIX}/json-c/lib64/pkgconfig:${PREFIX}/libxml2/lib/pkgconfig:$PKG_CONFIG_PATH

export PATH=${PREFIX}/sqlite3/bin:${PREFIX}/proj/bin:${PREFIX}/geos/bin:${PREFIX}/gdal/bin:${PREFIX}/sfcgal/bin:${PREFIX}/protobuf/bin:${PREFIX}/protobuf-c/bin:${PREFIX}/libxml2/bin:$PATH

Note

还有一个 ugc 的文件夹是 yukon_geomodel 的依赖文件,你可以从安装包中找到这个文件。然后将路径加入到``LD_LIBRARY_PATH`` 中。

Yukon for openGauss 编译

注意:在编译之前需要将 openGauss 缺少的头文件从其源码包中拷贝到数据库对应的 Include 目录下。

  1. 下载源码

    git clone https://gitee.com/opengauss/yukon.git
    
  2. 检查环境,生成编译脚本

    ./configure --without-topology  --without-address-standardizer --without-interrupt-tests CFLAGS='-O2 -fpermissive -DPGXC  -pthread ' CC=g++
    
  3. 编译安装

    make -j4 && make install
    

    到此,就可以在 openGauss 中使用 Yukon 了。

Yukon for PostgreSQL 编译

  1. 下载源码

    git clone https://gitee.com/isupermap/yukon4pgsql.git
    
  2. 生成 configure

    sh autogen.sh
    
  3. 检查环境,生成编译脚本

    ./configure --without-topology
    
  4. 编译,安装

    make -j4 && make install
    

    到此,就可以在 PostgreSQL 中使用 Yukon 了。