Only valid for pgRouting v1.x. For pgRouting v2.0 or higher see


For pgRouting version >= 1.0 RC1 (Previous versions cannot be compiled without TSP and Driving Distance functionality)


pgRouting Core - Shortest-Path algorithms

  • C and C++ compilers
  • Postgresql version >= 8.0
  • PostGIS version >= 1.0
  • The Boost Graph Library (BGL). Version >= 1.33 which contains the astar.hpp.

pgRouting Extra - with TSP

pgRouting Extra - with Driving Distance

Installation Instructions

Step 1: Libraries installation

Compile and install PostgreSQL, PostGIS, Proj, GEOS, BGL and GAUL. Usually it is sufficient to run:

# ./configure
# make
# make install

in corresponding directory.

If you have BGL installed but the version is less than 1.33.0, just download the astar.hpp file from and copy it to ‘’BOOST_PATH/graph’’ directory.

For Traveling Salesperson Problem (optional)

The GAUL library should be compiled with –enable-slang=no option. Otherwise make sure you have slang.h installed in ‘’/usr/include’‘. For more details please refer to corresponding ‘’README’’ or ‘’INSTALL’’ file.

# ./configure --disable-slang

For Driving Distance (optional)

For CGAL, the compile option below can be used to create the library:

# ./install_cgal --prefix=/usr --with-boost=n --without-autofind -ni /usr/bin/g++

CGAL needs special treatment!

After you install CGAL, you need to locate the directory with CGAL header files. In that directory you need to find ‘’config’’ subdirectory. This directory contains one or more subdirectories with platform-dependent information.

It may look like this, for example:

+- usr
  +- include
         +- CGAL
            +- config
               +- i686_Linux-2.6_g++4.1.1
               |  |
               |  +- CGAL
               |     |
               |     +- compiler_config.h   <<< this is the file you need
               +- msvc7
               |  |
               |  +- CGAL
               |     |
               |     +- compiler_config.h

All you need to do is to choose ‘’compiler_config.h’’ for your platform and make a symlink or copy it to the main headers directory.

For example:

# ln -s /usr/include/CGAL/config/i686_Linux-2.6_g++4.1.1/compiler_config.h /usr/include/CGAL/compiler_config.h

Step 2: Compiling the pgRouting library

  1. Get pgRouting source
  2. Change to pgRouting directory
  3. Compile and install pgRouting

For pgRouting core (required)

cmake .
make install

For pgRouting extras (optional)

# Add Traveling Salesperson functionality:  -DWITH_TSP=ON
# Add Driving Distance functionality     :  -DWITH_DD=ON

make install

If your program compiles but you get an error like the following one:

error while loading shared libraries: cannot open
shared object file: No such file or directory
  1. Add the library path (ie. /usr/local/pgsql/lib) to /etc/
  2. Run ldconfig

Maybe you installed PostgreSQL from Source-code, while compiling pgRouting you might get an error like

Output directory for libraries is set to sh: pg_config: command not found
ERROR: could not access file "$libdir/librouting

Then you need to type at the shell-console:

export PATH="$PATH:/usr/local/pgsql/bin"

presuming you installed PostgreSQL at /usr/local/pgsql/bin

Step 3: Create a routing database and load PostGIS and pgRouting functions

  1. Create a routing database and load PostGIS
createdb -U postgres -E UNICODE routing
createlang -U postgres plpgsql routing

psql -U postgres -f /path/to/postgis/lwpostgis.sql routing
psql -U postgres -f /path/to/postgis/spatial_ref_sys.sql routing
  1. Add pgRouting core functions (required)
psql -U postgres -f /usr/share/postlbs/routing_core.sql routing
psql -U postgres -f /usr/share/postlbs/routing_core_wrappers.sql routing
  1. Add pgRouting extra functions (optional)
# With TSP
psql -U postgres -f /usr/share/postlbs/routing_tsp.sql routing
psql -U postgres -f /usr/share/postlbs/routing_tsp_wrappers.sql routing

# With Driving Distance
psql -U postgres -f /usr/share/postlbs/routing_dd.sql routing
psql -U postgres -f /usr/share/postlbs/routing_dd_wrappers.sql routing