arbormagna nick Hi, just an update from my side. Building upon your script I have now a script that brings the process to the end, i.e. I have a working PostGIS extension:
# Install CMAKE
# make some dirs if they don't already exist, etc
mkdir -p $HOME/opt/src $HOME/bin $HOME/src && cd $HOME/opt/src
export PATH="$HOME/opt/bin:$PATH"
wget https://github.com/Kitware/CMake/archive/refs/tags/v3.27.8.tar.gz
tar zvxf v3.27.8.tar.gz
cd CMake-3.27.8/
./bootstrap --prefix=$HOME/opt
make -j9
make install
cd ~/bin
ln -s ~/opt/bin/* .
## Install other POSTGIS dependencies
# Set dev env stuff
scl enable devtoolset-11 bash
export PATH="$HOME/opt/bin:$PATH"
export PGHOME=$HOME/apps/psql15
export PGDATA=$HOME/apps/psql15/pgdata
mkdir -p $HOME/apps/psql15/pgdata
mkdir -p $PGHOME/src
export MY_PORT=XXXXX
export PATH="$PGHOME/bin:$PATH"
export LD_LIBRARY_PATH="$PGHOME/lib:$LD_LIBRARY_PATH"
export C_INCLUDE_PATH=$PGHOME/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$PGHOME/include:$CPLUS_INCLUDE_PATH
export CPPFLAGS="-I$PGHOME/include $CPPFLAGS"
export LDFLAGS="-L$PGHOME/lib $LDFLAGS"
# Install GEOS
cd $PGHOME/src
wget https://download.osgeo.org/geos/geos-3.10.5.tar.bz2
tar xvjf geos-3.10.5.tar.bz2
cd geos-3.10.5
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PGHOME \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/g++
make -j9
make install
#Download and install googletest
git clone https://github.com/google/googletest.git $PGHOME/src/googletest/
cd $PGHOME/src/googletest/
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PGHOME \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/g++ \
-DBUILD_SHARED_LIBS=ON
make -j9
make install
#Download and install sqlite3
cd $PGHOME/src
wget https://www.sqlite.org/2023/sqlite-autoconf-3440000.tar.gz
tar xvzf sqlite-autoconf-3440000.tar.gz
cd sqlite-autoconf-3440000
./configure --prefix=$PGHOME
make -j9
make install
#Download and install PROJ9
cd $PGHOME/src
wget https://download.osgeo.org/proj/proj-9.2.1.tar.gz
tar zvxf proj-9.2.1.tar.gz
cd proj-9.2.1/
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PGHOME \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/g++ \
-DSQLITE3_INCLUDE_DIR=$PGHOME/include \
-DSQLITE3_LIBRARY=$PGHOME/lib/libsqlite3.so
make -j9
make install
#Download and install json-c-0.16
cd $PGHOME/src
git clone https://github.com/json-c/json-c.git
cd json-c
git checkout remotes/origin/json-c-0.16
mkdir ../json-c-build
cd ../json-c-build
cmake ../json-c -DCMAKE_INSTALL_PREFIX=$PGHOME \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/g++
make -j9
make install
# Install GDAL
cd $PGHOME/src
wget https://github.com/OSGeo/gdal/releases/download/v3.6.4/gdal-3.6.4.tar.gz
tar zvxf gdal-3.6.4.tar.gz
cd gdal-3.6.4/
mkdir build && cd build
export LD_LIBRARY_PATH=$PGHOME/lib64:$LD_LIBRARY_PATH
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PGHOME \
-DCMAKE_C_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/gcc \
-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-11/root/usr/bin/g++ \
-DSQLITE3_INCLUDE_DIR=$PGHOME/include \
-DSQLITE3_LIBRARY=$PGHOME/lib/libsqlite3.so
cmake --build . -j9
cmake --build . --target install
# Download and install postgresql 15.4
cd $PGHOME/src
wget https://ftp.postgresql.org/pub/source/v15.4/postgresql-15.4.tar.gz
tar xvf postgresql-15.4.tar.gz
cd postgresql-15.4
LDFLAGS=-lstdc++ ./configure CC=/opt/rh/devtoolset-11/root/usr/bin/gcc \
--prefix=$PGHOME \
--with-pgport=$MY_PORT \
--with-ssl=openssl
make -j9
make install
# Download and install protobuf
cd $PGHOME/src
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout remotes/origin/4.0.x
./autogen.sh
./configure --prefix=$PGHOME
make -j9
make install
# Download and install protobuf-c
cd $PGHOME/src
wget https://github.com/protobuf-c/protobuf-c/releases/download/v1.4.0/protobuf-c-1.4.0.tar.gz
tar -xzvf protobuf-c-1.4.0.tar.gz
cd protobuf-c-1.4.0
export LD_LIBRARY_PATH=$PGHOME/lib64:$LD_LIBRARY_PATH
./configure --prefix=$PGHOME \
CC=/opt/rh/devtoolset-11/root/usr/bin/gcc \
protobuf_CFLAGS="-I$PGHOME/include" \
protobuf_LIBS="-L$PGHOME/lib -lprotobuf"
make -j9
make install
#Download and install gmp 6.3.0 (needed for SFCGAL)
cd $PGHOME/src
wget https://ftp.gnu.org/gnu/gmp/gmp-6.3.0.tar.xz
unxz gmp-6.3.0.tar.xz
tar -xvf gmp-6.3.0.tar
cd gmp-6.3.0
./configure --enable-cxx \
--prefix=$PGHOME
make -j9
make install
#Download and install mpfr 4.2.1 (needed for SFCGAL)
cd $PGHOME/src
wget https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.1.tar.gz
tar -xvf mpfr-4.2.1.tar.gz
cd mpfr-4.2.1
./configure --prefix=$PGHOME
make -j9
make install
# Download and install boost 1.83.0 (needed for SFCGAL)
cd $PGHOME/src
wget https://boostorg.jfrog.io/artifactory/main/release/1.83.0/source/boost_1_83_0.tar.gz
tar -xzvf boost_1_83_0.tar.gz
cd boost_1_83_0
export LD_LIBRARY_PATH=$PGHOME/lib64:$LD_LIBRARY_PATH
./bootstrap.sh --prefix=$PGHOME
./b2 install -j9
# Download and install CGAL-5.6 (needed for SFCGAL)
cd $PGHOME/src
wget https://github.com/CGAL/cgal/releases/download/v5.6/CGAL-5.6.tar.xz
tar -xvf CGAL-5.6.tar.xz
cd CGAL-5.6
mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PGHOME -DCMAKE_BUILD_TYPE="Release"
make -j9
make install
# Download and install SFCGAL-1.5.0
cd $PGHOME/src
wget https://gitlab.com/SFCGAL/SFCGAL/-/archive/v1.5.0/SFCGAL-v1.5.0.tar.gz
tar -xvf SFCGAL-v1.5.0.tar.gz
cd SFCGAL-v1.5.0
mkdir -p build
cd build
export CXX=c++
cmake .. -DCMAKE_INSTALL_PREFIX=$PGHOME \
-DCMAKE_BUILD_TYPE="Release"
make -j9
make install
# Install PostGIS
export LD_LIBRARY_PATH="$PGHOME/lib64:$PGHOME/lib:$LD_LIBRARY_PATH";
cd $PGHOME/src
wget https://download.osgeo.org/postgis/source/postgis-3.3.3.tar.gz
tar zvxf postgis-3.3.3.tar.gz
cd postgis-3.3.3/
export LDFLAGS="-L$PGHOME/lib64 -L$PGHOME/lib"
export CPPFLAGS="-I$PGHOME/include"
./configure --with-pgconfig=$PGHOME/bin/pg_config --with-gdalconfig=$PGHOME/bin/gdal-config --with-geosconfig=$PGHOME/bin/geos-config --with-projdir=$PGHOME --with-jsondir=$PGHOME
make -j9
make install
However, even though the PostGIS is built with all needed dependencies:
-------------- Dependencies --------------
GEOS config: /home/arbormagna/apps/psql15/bin/geos-config
GEOS version: 3.10.5
GDAL config: /home/arbormagna/apps/psql15/bin/gdal-config
GDAL version: 3.6.4
SFCGAL config: /home/arbormagna/apps/psql15/bin/sfcgal-config
SFCGAL version: 1.5.0
PostgreSQL config: /home/arbormagna/apps/psql15/bin/pg_config
PostgreSQL version: PostgreSQL 15.4
PROJ4 version: 92
Libxml2 config: /usr/bin/xml2-config
Libxml2 version: 2.9.1
JSON-C support: yes
protobuf support: yes
protobuf-c version: 1004000
PCRE support: Version 1
Perl: /usr/bin/perl
--------------- Extensions ---------------
PostGIS Raster: enabled
PostGIS Topology: enabled
SFCGAL support: enabled
Address Standardizer support: enabled
GDAL and SFCGAL are not available at run time (I figure they are not installed):
postgis_full_version
-------------------------------------------------------
-------------------------------------------------------
-----------------------------------------------------
POSTGIS="3.3.3 2355e8e" [EXTENSION] PGSQL="150" GEOS="
3.10.5-CAPI-1.16.2" PROJ="9.2.1" LIBXML="2.9.1" LIBJSON
="0.16" LIBPROTOBUF="1.4.0" WAGYU="0.5.0 (Internal)"
(1 row)
As a side note, if I add an option CC=/opt/rh/devtoolset-11/root/usr/bin/gcc
to PostGIS configuration I can not create PostGIS extension at run time (postgis can not find libproj.so). Could this mean that it can be related to compiler? Any insights are highly appreciated.