UbuntuInstallation

Dane Springmeyer edited this page Aug 10, 2018 · 56 revisions

Installing Mapnik on Ubuntu

For all versions of Ubuntu it is a good idea to be fully up to date before starting:

sudo apt-get update
sudo apt-get upgrade

For older versions, see the archived notes at UbuntuInstallationOld

Install Mapnik from source

# you might have to update your outdated clang
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update -y
sudo apt-get install -y gcc-6 g++-6 clang-3.8
export CXX="clang++-3.8" && export CC="clang-3.8"

# install mapnik
git clone https://github.com/mapnik/mapnik mapnik --depth 10
cd mapnik
git submodule update --init
sudo apt-get install python zlib1g-dev clang make pkg-config curl
source bootstrap.sh
./configure CUSTOM_CXXFLAGS="-D_GLIBCXX_USE_CXX11_ABI=0" CXX=${CXX} CC=${CC}
make
make test
sudo make install

NOTE: there used to be a community PPA maintained for Mapnik apt packages (https://launchpad.net/~mapnik/+archive), but it is no longer maintained or in use.


Detailed/historical notes

First, remove any other old mapnik packages:

sudo apt-get purge libmapnik* mapnik-* python-mapnik

Ensure your boost version is recent enough (at least 1.47)

Mapnik master may require a boost version more recent than provided by your Ubuntu distribution.

Ubuntu 12.04 Precise ships with 2 different boost versions: 1.46 and 1.48. Make sure you install the correct version.

Note: You can see the boost version offered by your distro with the below command.

apt-cache policy libboost-dev

Set up build environment

    # On Ubuntu 12.04 Precise, make sure you get the 1.48 boost packages:
    sudo apt-get install \
    libboost-filesystem1.48-dev \
    libboost-program-options1.48-dev \
    libboost-python1.48-dev libboost-regex1.48-dev \
    libboost-system1.48-dev libboost-thread1.48-dev

    # On on some systems just:
    sudo apt-get install \
    libboost-filesystem-dev \
    libboost-program-options-dev \
    libboost-python-dev libboost-regex-dev \
    libboost-system-dev libboost-thread-dev \

    # get a build environment going...
    sudo apt-get install \
    libicu-dev \
    python-dev libxml2 libxml2-dev \
    libfreetype6 libfreetype6-dev \
    libjpeg-dev \
    libpng-dev \
    libproj-dev \
    libtiff-dev \
    libcairo2 libcairo2-dev python-cairo python-cairo-dev \
    libcairomm-1.0-1 libcairomm-1.0-dev \
    ttf-unifont ttf-dejavu ttf-dejavu-core ttf-dejavu-extra \
    git build-essential python-nose \
    libgdal1-dev python-gdal \
    postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgresql-9.1-postgis \
    libsqlite3-dev

Note: for Ubuntu >=14.04 postgres/postgis versions have shifted, so do:

sudo apt-get install -y postgresql-9.3 postgresql-server-dev-9.3 postgresql-contrib-9.3 postgresql-9.3-postgis-2.1

Source install of Mapnik 2.3.x

# For the development branch:
git clone https://github.com/mapnik/mapnik mapnik-2.3.x -b 2.3.x --depth 10
cd mapnik-2.3.x
./configure && make && sudo make install

Source install of Mapnik Master (3.x)

First download, compile and install harfbuzz

wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.34.tar.bz2
tar xf harfbuzz-0.9.34.tar.bz2
cd harfbuzz-0.9.34
./configure && make && sudo make install
sudo ldconfig
cd ../

Upgrade your compiler to at least g++ 4.7 so it supports c++11 features.
apt-get upgrade should give you g++-4.8 and gcc-4.8):

apt-get update
apt-get upgrade
git clone https://github.com/mapnik/mapnik --depth 10
cd mapnik
git submodule update --init deps/mapbox/variant
./configure
make && sudo make install

If that doesn't work, here is an example for ubuntu precise to upgrade compilers:

CLANG_VERSION=3.6
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
sudo add-apt-repository "deb http://llvm.org/apt/precise/ llvm-toolchain-precise-${CLANG_VERSION} main";
wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-get update -y
sudo apt-get install -y clang-3.6;
export CXX="clang++-3.6" && export CC="clang-3.6";
git clone https://github.com/mapnik/mapnik --depth 10
cd mapnik
./configure CXX=${CXX} CC=${CC}
make && sudo make install

Testing

To test mapnik:

make test
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.