pgRouting

Installation Manual

Step 1: Libraries installation

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

# ./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 http://www.boost.org/boost/graph/astar_search.hpp 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 will install CGAL, you will need to locate the directory with CGAL header files. In that directory you will need to find config directory. This directory will contain 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
           |
          etc...

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 derectory.
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
    make install
    
  • For pgRouting extras (optional)
    # Add Traveling Salesperson functionality:  -DWITH_TSP=ON
    # Add Driving Distance functionality     :  -DWITH_DD=ON
    
    cmake -DWITH_TSP=ON -DWITH_DD=ON .
    make
    make install
    

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

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

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