Table of Contents
Short Version
Get the sources
Enabling and upgrading in the database
Dependencies
Configuring
Building
Testing
Instructions for downloading and installing binaries for different operatingsystems, additional notes and corrections not included in this documentation canbe found in Installation wiki
To use pgRouting PostGIS needs to be installed, please read the informationabout installation in this Install Guide
Short Version¶
Extracting the tar ball
tar xvfz pgrouting-3.5.1.tar.gzcd pgrouting-3.5.1
To compile assuming you have all the dependencies in your search path:
mkdir buildcd buildcmake ..makesudo make install
Once pgRouting is installed, it needs to be enabled in each individualdatabase you want to use it in.
createdb routingpsql routing -c 'CREATE EXTENSION PostGIS'psql routing -c 'CREATE EXTENSION pgRouting'
Get the sources¶
The pgRouting latest release can be found inhttps://github.com/pgRouting/pgrouting/releases/latest
wget
To download this release:
wget -O pgrouting-3.5.1.tar.gz https://github.com/pgRouting/pgrouting/archive/v3.5.1.tar.gz
Go to Short Version for more instructions on extracting tar ball andcompiling pgRouting.
git
To download the repository
git clone git://github.com/pgRouting/pgrouting.gitcd pgroutinggit checkout v3.5.1
Go to Short Version for more instructions on compiling pgRouting(there is no tar ball involved while downloading pgRouting repository fromGitHub).
Enabling and upgrading in the database¶
Enabling the database
pgRouting is a PostgreSQL extension and depends on PostGIS to providefunctionalities to end user. Below given code demonstrates enabling PostGIS andpgRouting in the database.
CREATE EXTENSION postgis;CREATE EXTENSION pgrouting;
Checking PostGIS and pgRouting version after enabling them in the database.
SELECT PostGIS_full_version();SELECT * FROM pgr_version();
Upgrading the database
To upgrade pgRouting in the database to version 3.5.1 use thefollowing command:
ALTER EXTENSION pgrouting UPDATE TO "3.5.1";
More information can be found inhttps://www.postgresql.org/docs/current/sql-createextension.html
Dependencies¶
Compilation Dependencies
To be able to compile pgRouting, make sure that the following dependencies aremet:
C and C++0x compilers
Compiling with Boost 1.56 up to Boost 1.74 requires C++ Compiler withC++03 or C++11 standard support
Compiling with Boost 1.75 requires C++ Compiler with C++14 standardsupport
Postgresql version = Supported versions by PostgreSQL
The Boost Graph Library (BGL). Version >= 1.56
CMake >= 3.2
optional dependencies
For user’s documentation
Sphinx >= 1.1
Latex
For developer’s documentation
Doxygen >= 1.7
For testing
pgtap
pg_prove
For using:
PostGIS version >= 2.2
Example: Installing dependencies on linux
Installing the compilation dependencies
Database dependencies
sudo apt install postgresql-15sudo apt install postgresql-server-dev-15sudo apt install postgresql-15-postgis
Configuring PostgreSQL
Entering psql console
sudo systemctl start postgresql.servicesudo -i -u postgrespsql
To exit psql console
q
Entering psql console directly without switching roles can be done by thefollowing commands
sudo -u postgres psql
Then use the above given method to exit out of the psql console
Checking PostgreSQL version
psql --version
or
Enter the psql console using above given method and then enter
SELECT VERSION();
Creating PostgreSQL role
sudo -i -u postgrescreateuser --interactive
or
sudo -u postgres createuser --interactive
Default role provided by PostgreSQL is postgres. To create new roles youcan use the above provided commands. The prompt will ask the user to typename of the role and then provide affirmation. Proceed with the steps andyou will succeed in creating PostgreSQL role successfully.
To add password to the role or change previously created password of therole use the following commands
ALTER USER <role name> PASSWORD <password>
To get additional details on the flags associated with createuser
belowgiven command can be used
man createuser
Creating Database in PostgreSQL
sudo -i -u postgrescreatedb <database name>
or
sudo -u postgres createdb <database name>
Connecting to a PostgreSQL Database
Enter the psql console and type the following commands
connect <database name>
Build dependencies
sudo apt install cmakesudo apt install g++sudo apt install libboost-graph-dev
Optional dependencies
For documentation and testing
pip install sphinxpip install sphinx-bootstrap-themesudo apt install texlivesudo apt install doxygensudo apt install libtap-parser-sourcehandler-pgtap-perlsudo apt install postgresql-15-pgtap
Configuring¶
pgRouting uses the cmake system to do the configuration.
The build directory is different from the source directory
Create the build directory
$ mkdir build
Configurable variables¶
To see the variables that can be configured
$ cd build$ cmake -L ..
Configuring The Documentation
Most of the effort of the documentation has been on the HTML files.Some variables for building documentation:
Variable | Default | Comment |
---|---|---|
WITH_DOC | BOOL=OFF | Turn on/off building the documentation |
BUILD_HTML | BOOL=ON | If ON, turn on/off building HTML for user’sdocumentation |
BUILD_DOXY | BOOL=ON | If ON, turn on/off building HTML for developer’sdocumentation |
BUILD_LATEX | BOOL=OFF | If ON, turn on/off building PDF |
BUILD_MAN | BOOL=OFF | If ON, turn on/off building MAN pages |
DOC_USE_BOOTSTRAP | BOOL=OFF | If ON, use sphinx-bootstrap for HTML pages of theusers documentation |
Configuring cmake to create documentation before buildingpgRouting
$ cmake -DWITH_DOC=ON -DDOC_USE_BOOTSTRAP=ON ..
Note
Most of the effort of the documentation has been on the html files.
Building¶
Using make
to build the code and the documentation
The following instructions start from path/to/pgrouting/build
$ make # build the code but not the documentation$ make doc # build only the user's documentation$ make all doc # build both the code and the user's documentation$ make doxy # build only the developer's documentation
We have tested on several platforms, For installing or reinstalling all thesteps are needed.
Warning
The sql signatures are configured and build in the cmake
command.
MinGW on Windows
$ mkdir build$ cd build$ cmake -G"MSYS Makefiles" ..$ make$ make install
Linux
The following instructions start from path/to/pgrouting
mkdir buildcd buildcmake ..makesudo make install
To remove the build when the configuration changes, use the followingcode:
rm -rf build
and start the build process as mentioned previously.
Testing¶
Currently there is no make test
and testing is done as follows
The following instructions start from path/to/pgrouting/
tools/testers/doc_queries_generator.plcreatedb -U <user> ___pgr___test___sh ./tools/testers/pg_prove_tests.sh <user>dropdb -U <user> ___pgr___test___
See Also¶
Indices and tables
Index
Search Page