Skip to content

Instantly share code, notes, and snippets.

@vinnix
Last active July 28, 2018 23:53
Show Gist options
  • Save vinnix/5590342ba725244f744ca0f7b3b367d4 to your computer and use it in GitHub Desktop.
Save vinnix/5590342ba725244f744ca0f7b3b367d4 to your computer and use it in GitHub Desktop.
QGIS how to build on CentOS 7 - step by step
## Steps not a script (yet)
## #!/bin/env bash
## <optional>
## you want to have PostgreSQL / PostGIS installed from PostgreSQL repo
$ wget https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
$ rpm -ivh rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
$ sudo yum install CGAL.x86_64 \
SFCGAL.x86_64 \
SFCGAL-libs.x86_64 \
gdal.x86_64 \
gdal-devel.x86_64 \
gdal-libs.x86_64 \
gdal-python.x86_64 \
geos.x86_64 \
geos-devel.x86_64 \
geos36.x86_64 \
geos36-devel.x86_64 \
geos36-python.x86_64 \
libgeotiff.x86_64 \
libpqxx.x86_64 \
ogr_fdw96.x86_64 \
osm2pgrouting_96.x86_64 \
pgrouting_96.x86_64 \
postgis23_96.x86_64 \
postgis23_96-client.x86_64 \
postgis23_96-devel.x86_64 \
postgis23_96-utils.x86_64 \
postgresql96.x86_64 \
postgresql96-contrib.x86_64 \
postgresql96-devel.x86_64 \
postgresql96-libs.x86_64 \
postgresql96-server.x86_64 \
proj49.x86_64 \
python-jinja2.noarch \
python-psycopg2.x86_64 -y
##
## </optional>
yum install libpng-devel.x86_64
############################################################################
## What I am doing to build at CentOS 7
############################################################################
## those repositories are needed
$ sudo yum install epel-release.noarch centos-release-scl -y
## gcc 7 and building tools are needed
$ sudo yum install devtoolset-7.x86_64 \
devtoolset-7-binutils.x86_64 \
devtoolset-7-dwz.x86_64 \
devtoolset-7-dyninst.x86_64 \
devtoolset-7-elfutils.x86_64 \
devtoolset-7-elfutils-libelf.x86_64 \
devtoolset-7-elfutils-libs.x86_64 \
devtoolset-7-gcc.x86_64 \
devtoolset-7-gcc-c++.x86_64 \
devtoolset-7-gcc-gfortran.x86_64 \
devtoolset-7-gdb.x86_64 \
devtoolset-7-libquadmath-devel.x86_64 \
devtoolset-7-libstdc++-devel.x86_64 \
devtoolset-7-ltrace.x86_64 \
devtoolset-7-make.x86_64 \
devtoolset-7-memstomp.x86_64 \
devtoolset-7-oprofile.x86_64 \
devtoolset-7-perftools.x86_64 \
devtoolset-7-runtime.x86_64 \
devtoolset-7-strace.x86_64 \
devtoolset-7-systemtap.x86_64 \
devtoolset-7-systemtap-client.x86_64 \
devtoolset-7-systemtap-devel.x86_64 \
devtoolset-7-systemtap-runtime.x86_64 \
devtoolset-7-toolchain.x86_64 \
devtoolset-7-valgrind.x86_64 -y
## building with Qt5
$ sudo yum install qca-qt5.x86_64 \
qca-qt5-devel.x86_64 \
qca-qt5-gcrypt.x86_64 \
qca-qt5-gnupg.x86_64 \
qca-qt5-ossl.x86_64 \
qca-qt5-pkcs11.x86_64 \
qt5-designer.x86_64 \
qt5-doctools.x86_64 \
qt5-linguist.x86_64 \
qt5-qtbase.x86_64 \
qt5-qtbase-common.noarch \
qt5-qtbase-devel.x86_64 \
qt5-qtbase-gui.x86_64 \
qt5-qtdeclarative.x86_64 \
qt5-qtdeclarative-devel.x86_64 \
qt5-qtlocation.x86_64 \
qt5-qtlocation-devel.x86_64 \
qt5-qtscript.x86_64 \
qt5-qtscript-devel.x86_64 \
qt5-qtsensors.x86_64 \
qt5-qtserialport.x86_64 \
qt5-qtserialport-devel.x86_64 \
qt5-qtsvg.x86_64 \
qt5-qtsvg-devel.x86_64 \
qt5-qttools.x86_64 \
qt5-qttools-common.noarch \
qt5-qttools-devel.x86_64 \
qt5-qttools-libs-designer.x86_64 \
qt5-qttools-libs-designercomponents.x86_64 \
qt5-qttools-libs-help.x86_64 \
qt5-qttools-static.x86_64 \
qt5-qtwebchannel.x86_64 \
qt5-qtwebkit.x86_64 \
qt5-qtwebkit-devel.x86_64 \
qt5-qtx11extras.x86_64 \
qt5-qtxmlpatterns.x86_64 \
qt5-qtxmlpatterns-devel.x86_64 \
qt5-rpm-macros.noarch \
qtermwidget-qt5.x86_64 \
qtermwidget-qt5-devel.x86_64 \
qtkeychain-qt5.x86_64 \
qtkeychain-qt5-devel.x86_64 -y
## python3.6
$ sudo yum install rh-python36.x86_64 \
rh-python36-build.x86_64 \
rh-python36-python.x86_64 \
rh-python36-python-devel.x86_64 \
rh-python36-python-libs.x86_64 \
rh-python36-python-pip.noarch \
rh-python36-python-setuptools.noarch \
rh-python36-python-tkinter.x86_64 \
rh-python36-python-tools.x86_64 \
rh-python36-python-virtualenv.noarch \
rh-python36-runtime.x86_64 \
rh-python36-scldevel.x86_64 -y
## GDAL Bulding steps
## https://gist.github.com/robinkraft/2a8ee4dd7e9ee9126030
## https://trac.osgeo.org/gdal/wiki/BuildingOnUnix
## Be aware: You will have two GDAL versions installed, one for PostgreSQL/PostGIS (server) and other for Quantum GIS (client)
## enabling python3.6 and gcc 7 environment (to avoid conflicts with default CentOS 7 environments)
$ scl enable rh-python36 devtoolset-7 bash
$ wget http://download.osgeo.org/gdal/2.1.4/gdal-2.1.4.tar.gz
$ tar xvzf gdal-2.1.4.tar.gz
$ cd gdal-2.1.4/
$ CFLAGS="-g -Wall" LDFLAGS="-s" ./configure --prefix=/usr/local/gdal \
--with-pcraster=internal \
--with-pg=/usr/pgsql-9.6/bin/pg_config \
--with-libtiff=internal \
--with-geotiff=internal \
--with-jpeg=internal \
--with-gif=internal \
--with-ecw=no \
--with-expat=yes \
--with-sqlite3=yes \
--with-geos=yes \
--with-python \
--with-libz=internal \
--with-netcdf \
--with-threads=yes \
--without-grass \
--without-ogdi \
--with-xerces=yes
## --with-png=internal
$ make -j3
$ make install
$ echo "/usr/local/gdal/lib/" >> /etc/ld.so.conf
$ ldconfig
##
$ export PATH="/usr/local/gdal/bin:/opt/rh/devtoolset-7/root/usr/bin:/opt/rh/rh-python36/root/usr/bin:/opt/node/bin:/home/vinnix/.local/bin:/home/vinnix/bin:/usr/pgsql-9.6/bin/:/usr/lib64/qt5/bin:/home/vinnix/perl5/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"
$ yum install sqlite-devel.x86_64 proj-devel.x86_64 freexl-devel.x86_64 libxml2-devel.x86_64
##
##
$ wget http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-4.2.0.zip
$ unzip libspatialite-4.2.0.zip
$ cd libspatialite-4.2.0/
$ ./configure
$ make
$ sudo make install
##
##
$ wget https://downloads.sourceforge.net/project/qwt/qwt/6.1.3/qwt-6.1.3.zip
$ unzip qwt-6.1.3.zip
$ cd qwt-6.1.3
$ /usr/lib64/qt5/bin/qmake-qt5
$ make -j3
$ sudo make install
$ echo "/usr/local/qwt-6.1.3/lib" >> /etc/ld.so.conf
$ ldconfig
##
##
$ wget https://downloads.sourceforge.net/project/pyqt/sip/sip-4.19.12/sip-4.19.12.zip
$ tar xvzf sip-4.19.12.tar.gz
$ cd sip-4.19.12
$ python configure.py
$ make
$ sudo make install
##
$ wget https://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.9.2/PyQt5_gpl-5.9.2.tar.gz
$ tar xvzf PyQt5_gpl-5.9.2.tar.gz
$ cd PyQt5_gpl-5.9.2
$ python3 configure.py --qmake=/usr/lib64/qt5/bin/qmake-qt5 -w --confirm-license
$ make
$ sudo make install
$ wget https://downloads.sourceforge.net/project/pyqt/QScintilla2/QScintilla-2.10.7/QScintilla_gpl-2.10.7.tar.gz
$ tar xvzf QScintilla_gpl-2.10.7.tar.gz
$ cd QScintilla_gpl-2.10.7/Qt4Qt5
$ /usr/lib64/qt5/bin/qmake-qt5
$ make
$ sudo make install
$ cd ../Python
$ vim configure.py ## change pyqt4_is_supported to False at line 91
$ python3 configure.py
$ make
$ sudo make install
## Bulding GDAL python module manually (might be needed if installing directly from pip3 does not work)
## You/we need a version that is compatible with the GDAL library itself
## ALso, make sure that the correct 'gdal-config' is on the $PATH, since you/we may have two GDAL libraries in the host
$ pip3 download GDAL==2.1.3
$ tar xvzf GDAL-2.3.1.tar.gz
$ cd GDAL-2.3.1/
$ python3 setup.py build
$ python3 setup.py install
$ sudo yum install dbus-devel.x86_64 glib2-devel.x86_64 txt2tags -y
##
##
$ sudo pip3 install --upgrade pip
$ sudo pip3 install certifi \
chardet \
dbus-python \
django-osgeo-importer-client \
future \
GDAL \
idna \
Jinja2 \
MarkupSafe \
numpy \
OWSLib \
pip \
psycopg2 \
psycopg2-binary \
Pygments \
pyproj \
pyqt-units \
python-dateutil \
pytz \
PyYAML \
QScintilla \
requests \
setuptools \
sip \
six \
scipy \
urllib3 \
virtualenv
## TRICKY!!!
## Change the first line to '#!/usr/bin/env python2'
## (default is only 'python' which is pointing to python3 due SCL, and txt2tags does not work with python3)
$ sudo vim /bin/txt2tags
## 'ccmake3' command is needed to install QGIS
$ sudo yum install cmake3.x86_64 \
cmake3-data.noarch \
cmake3-gui.x86_64 \
bison \
flex \
libzip \
libzip-devel \
gsl-devel.x86_64 \
gsl.x86_64 \
expat-devel.x86_64 \
expat.x86_64 \
spatialindex-devel.x86_64 \
spatialindex.x86_64 \
-y
##
## Bulding Quantum GIS
##
$ git clone https://github.com/qgis/QGIS.git
$ cd QGIS
$ mkdir build-master
$ cd build-master
$ ccmake3 .. \
-DGDAL_CONFIG="/usr/local/gdal/bin/gdal-config" \
-DGDAL_LIBRARY="/usr/local/gdal/lib/libgdal.so" \
-DPOSTGRES_CONFIG="/usr/pgsql-9.6/bin/pg_config" \
-DPOSTGRES_CONFIG_PREFER_PATH="/usr/pgsql-9.6/bin" \
-DPOSTGRES_LIBRARY="/usr/pgsql-9.6/lib/libpq.so" \
-DPYTHON_LIBRARY="/opt/rh/rh-python36/root/usr/lib64/libpython3.6m.so" \
-DQWT_INCLUDE_DIR="/usr/local/qwt-6.1.3/include" \
-DQWT_LIBRARY="/usr/local/qwt-6.1.3/lib/libqwt.so"
## Press 'c' (to check configuration), then, 'g' (to generate the Makefile). Neat.
## Now buld with all you have. I have 4 CPUs to build, even so it took some hours.
$ make -j4
$ make install
## Testing
$ cd output/bin
$ ./qgis
$ sudo yum install gnu-free-fonts-common.noarch \
gnu-free-mono-fonts.noarch \
gnu-free-sans-fonts.noarch \
gnu-free-serif-fonts.noarch \
xorg-x11-fonts-misc -y
## $ pip3 list installed
##
## Package Version
## ---------------------------- ---------
## certifi 2018.4.16
## chardet 3.0.4
## dbus-python 1.2.8
## django-osgeo-importer-client 0.1.0
## future 0.16.0
## GDAL 2.1.4
## idna 2.7
## Jinja2 2.10
## MarkupSafe 1.0
## numpy 1.14.5
## OWSLib 0.16.0
## pip 10.0.1
## psycopg2 2.7.5
## psycopg2-binary 2.7.5
## Pygments 2.2.0
## pyproj 1.9.5.1
## pyqt-units 2.0
## python-dateutil 2.7.3
## pytz 2018.5
## PyYAML 3.13
## QScintilla 2.10.7
## requests 2.19.1
## scipy 1.1.0
## setuptools 36.5.0
## sip 4.19.12
## six 1.11.0
## urllib3 1.23
## virtualenv 15.1.0
##
## $ yum list installed | grep "pgdg96"
## CGAL.x86_64 4.7-1.rhel7 @pgdg96
## SFCGAL.x86_64 1.2.2-1.rhel7 @pgdg96
## SFCGAL-libs.x86_64 1.2.2-1.rhel7 @pgdg96
## gdal.x86_64 1.11.4-12.rhel7 @pgdg96
## gdal-devel.x86_64 1.11.4-12.rhel7 @pgdg96
## gdal-libs.x86_64 1.11.4-12.rhel7 @pgdg96
## gdal-python.x86_64 1.11.4-12.rhel7 @pgdg96
## geos.x86_64 3.5.0-1.rhel7 @pgdg96
## geos-devel.x86_64 3.5.0-1.rhel7 @pgdg96
## geos36.x86_64 3.6.2-3.1.rhel7 @pgdg96
## geos36-devel.x86_64 3.6.2-3.1.rhel7 @pgdg96
## geos36-python.x86_64 3.6.2-3.1.rhel7 @pgdg96
## libgeotiff.x86_64 1.4.0-1.rhel7 @pgdg96
## libpqxx.x86_64 1:5.0.1-2.rhel7 @pgdg96
## ogr_fdw96.x86_64 1.0.5-1.rhel7 @pgdg96
## osm2pgrouting_96.x86_64 2.3.5-1.rhel7 @pgdg96
## pgrouting_96.x86_64 2.6.0-1.rhel7 @pgdg96
## postgis23_96.x86_64 2.3.7-1.rhel7 @pgdg96
## postgis23_96-client.x86_64 2.3.7-1.rhel7 @pgdg96
## postgis23_96-devel.x86_64 2.3.7-1.rhel7 @pgdg96
## postgis23_96-utils.x86_64 2.3.7-1.rhel7 @pgdg96
## postgresql96.x86_64 9.6.9-1PGDG.rhel7 @pgdg96
## postgresql96-contrib.x86_64 9.6.9-1PGDG.rhel7 @pgdg96
## postgresql96-devel.x86_64 9.6.9-1PGDG.rhel7 @pgdg96
## postgresql96-libs.x86_64 9.6.9-1PGDG.rhel7 @pgdg96
## postgresql96-server.x86_64 9.6.9-1PGDG.rhel7 @pgdg96
## proj49.x86_64 4.9.3-3.rhel7 @pgdg96
## python-jinja2.noarch 2.8-7.rhel7 @pgdg96
## python-psycopg2.x86_64 2.7.5-1.rhel7 @pgdg96
@vinnix
Copy link
Author

vinnix commented Jul 21, 2018

quantum_gis

"It's alive!"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment