root/trunk/INSTALL

Revision 765, 9.4 kB (checked in by dane, 5 days ago)

increment python version required to build to Python 2.2

  • Property svn:keywords set to Id
Line 
1# $Id$
2
3INSTALLATION INSTRUCTIONS
4
5
6Quick Start
7-----------
8
9Install needed dependencies::
10
11  $ sudo aptitude install libboost-filesystem-dev postgresql libgdal ...
12  $ cd ~/src/mapnik
13
14Build source code::
15
16  $ python scons/scons.py
17
18Install mapnik libs and python bindings::
19
20  $ sudo python scons/scons.py install
21
22Run python interpreter and check installation::
23
24  >>> from mapnik import *
25  Traceback (most recent call last):
26   File "<stdin>", line 1, in <module>
27  ImportError: No module named mapnik
28  >>>
29
30If you get this error ensure that Mapnik in is your PYTHONPATH.
31
32Otherwise your setup is ready. You can now visit http://trac.mapnik.org/wiki/GettingStarted for a basic tutorial.
33
34For troubleshooting other errors see: http://trac.mapnik.org/wiki/InstallationTroubleshooting.
35
36Prerequisites
37-------------
38
39First, here is a quick list of the software dependencies:
40
41- Linux/UNIX with g++ compiler
42
43- libboost 1.33.0 or greater with the following libraries included:
44        - thread
45        - system (boost >= 1.35 only)
46        - filesystem
47        - regex
48        - iostreams
49        - (Optional) program_options
50        - (Optional) python
51- libicu - International Components for Unicode
52- libpng
53- libjpeg
54- libtiff
55- libz
56- libfreetype2
57- pkg-config - Used for checking for cairo support
58- (Optional) tinyxml, spirit, or libxml2 - XML Parsing libraries
59- (Optional) PostgreSQL libraries (For PostGIS support)
60- (Optional) PROJ.4 (More on this below)
61- (Optional) GDAL
62- Python 2.2 or greater to build Mapnik
63- (Optional) Python 2.4 or greater for the Python language bindings
64
65Some of these will come pre-installed on modern Linux/UNIX systems, including Mac OS X. The Boost libraries are an exception, but can be installed using aptitude/apt-get on debian systems or macports/fink on OS X.
66
67If your system does NOT have one of these installed, you will need to install the mandatory ones at the very least before proceeding further.  Instructions on how to do this will come with each individual package.
68
69An an example on Ubuntu the aptitude package manager can be used to install the latest versions of all mapnik dependencies in one fell swoop:
70
71$ aptitude install libboost-thread-dev libboost-filesystem-dev libboost-regex-dev libboost-program-options-dev libboost-python-dev libboost-serialization-dev libpng12-dev libjpeg62-dev libtiff4-dev zlib1g-dev libfreetype6-dev libltdl3-dev libfribidi-dev debhelper libboost-iostreams-dev libcairo libcairo-dev python-cairo libcairomm-1.0-1 libcairomm-1.0-dev libicu-dev postgresql libgdal-dev postgis proj
72
73Also, a minimum of 256MB of RAM is recommended for the build process.
74
75
76Building
77--------
78
79Once you've installed the required software packages, the simplest way to build mapnik is to run "scons" (The software builder) without any options::
80
81  $ cd /path/to/mapnik-sourcecode
82  $ /path/to/python scons/scons.py
83
84This should compile and link the mapnik library, the input plugins and the python language binding (if possible).  If any mandatory dependencies are not found the build will fail, and you will need to specify custom paths to your libraries and include files (see below).
85
86Note that the python used to run "scons" does NOT have to be the same as the one used for the python bindings.
87
88"scons" accepts a variety of options to customize your build.  This allows you to specify which components are compiled, where to find dependencies, where to install mapnik, and so on.
89
90To see the list of available options, from the root of the source distribution, run::
91
92  $ /path/to/python scons/scons.py -h
93
94You will get::
95
96  CXX: The C++ compiler to use (defaults to g++).
97      default: g++
98      actual: g++
99 
100  PREFIX: The install path "prefix"
101      default: /usr/local
102      actual: /usr/local
103 
104  BOOST_INCLUDES: Search path for boost include files ( /path/to/BOOST_INCLUDES )
105      default: /usr/include
106      actual: /usr/include
107 
108  BOOST_LIBS: Search path for boost library files ( /path/to/BOOST_LIBS )
109      default: /usr/lib
110      actual: /usr/lib
111 
112  BOOST_TOOLKIT: Specify boost toolkit e.g. gcc41.
113      default:
114      actual:
115 
116  FREETYPE_CONFIG: The path to the freetype-config executable.
117      default: freetype-config
118      actual: freetype-config
119 
120  XML2_CONFIG: The path to the xml2-config executable.
121      default: xml2-config
122      actual: xml2-config
123 
124  ICU_INCLUDES: Search path for ICU include files ( /path/to/ICU_INCLUDES )
125      default: /usr/include
126      actual: /usr/include
127 
128  ICU_LIBS: Search path for ICU include files ( /path/to/ICU_LIBS )
129      default: /usr/lib
130      actual: /usr/lib
131 
132  PNG_INCLUDES: Search path for libpng include files ( /path/to/PNG_INCLUDES )
133      default: /usr/include
134      actual: /usr/include
135 
136  PNG_LIBS: Search path for libpng include files ( /path/to/PNG_LIBS )
137      default: /usr/lib
138      actual: /usr/lib
139 
140  JPEG_INCLUDES: Search path for libjpeg include files ( /path/to/JPEG_INCLUDES )
141      default: /usr/include
142      actual: /usr/include
143 
144  JPEG_LIBS: Search path for libjpeg library files ( /path/to/JPEG_LIBS )
145      default: /usr/lib
146      actual: /usr/lib
147 
148  TIFF_INCLUDES: Search path for libtiff include files ( /path/to/TIFF_INCLUDES )
149      default: /usr/include
150      actual: /usr/include
151 
152  TIFF_LIBS: Search path for libtiff library files ( /path/to/TIFF_LIBS )
153      default: /usr/lib
154      actual: /usr/lib
155 
156  PGSQL_INCLUDES: Search path for PostgreSQL include files ( /path/to/PGSQL_INCLUDES )
157      default: /usr/include
158      actual: /usr/include
159 
160  PGSQL_LIBS: Search path for PostgreSQL library files ( /path/to/PGSQL_LIBS )
161      default: /usr/lib
162      actual: /usr/lib
163 
164  PROJ_INCLUDES: Search path for PROJ.4 include files ( /path/to/PROJ_INCLUDES )
165      default: /usr/local/include
166      actual: /usr/local/include
167 
168  PROJ_LIBS: Search path for PROJ.4 library files ( /path/to/PROJ_LIBS )
169      default: /usr/local/lib
170      actual: /usr/local/lib
171 
172  GDAL_INCLUDES: Search path for GDAL include files ( /path/to/GDAL_INCLUDES )
173      default: /usr/include
174      actual: /usr/include
175 
176  GDAL_LIBS: Search path for GDAL library files ( /path/to/GDAL_LIBS )
177      default: /usr/lib
178      actual: /usr/lib
179 
180  PYTHON: Python executable ( /path/to/PYTHON )
181      default: /usr/bin/python
182      actual: /usr/bin/python
183 
184  INPUT_PLUGINS: Input drivers to include
185      (all|none|comma-separated list of names)
186      allowed names: postgis shape raster gdal
187      default: all
188      actual: postgis shape raster gdal
189 
190  BINDINGS: Language bindings to build
191      (all|none|comma-separated list of names)
192      allowed names: python
193      default: all
194      actual: python
195 
196  DEBUG: Compile a debug version of mapnik (yes|no)
197      default: False
198      actual: False
199 
200  DESTDIR: The root directory to install into. Useful mainly for binary package building
201      default: /
202      actual: /
203 
204  THREADING: Set threading support (multi|single)
205      default: multi
206      actual: multi
207 
208  XMLPARSER: Set xml parser  (tinyxml|spirit|libxml2)
209      default: tinyxml
210      actual: tinyxml
211
212
213This help should be self-explanatory!
214
215For example, if you compiled your own set of Boost libraries, you might use::
216
217  $ /path/to/python scons/scons.py BOOST_INCLUDES=/usr/local/include/boost-1_33_1 BOOST_LIBS=/usr/local/lib
218
219Or if you installed Postgres and Gdal from source and you'd like to build mapnik in Debug mode with the ability for XML parsing, you might use::
220
221  $ /path/to/python scons/scons.py DEBUG=y PGSQL_INCLUDES=/usr/local/pgsql/include PGSQL_LIBS=/usr/local/pgsql/lib XMLPARSER=libxml2
222
223
224Installation
225------------
226
227Once the build has successfully completed, you can install the various files on your system by executing::
228
229  $ /path/to/python scons/scons.py install
230
231By default, everything will be installed under the PREFIX '/usr/local' as such::
232
233  $PREFIX/lib: libmapnik.so
234  $PREFIX/lib/mapnik/input: input plug-ins
235  $PREFIX/include: mapnik include files
236  $PREFIX/bin: shapeindex utility
237  $PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages/mapnik: Python bindings
238
239If you're using the default PREFIX, you will most likely need to be root to perform the install.
240
241
242Testing Installation
243--------------------
244
245There currently is no easy way to test your setup, other than write some code to generate a map.
246
247One simple thing you can do is try to load the Python module in a python interpreter, and make sure it does so without errors::
248
249  $ /path/to/python
250  Python 2.4.2 (#1, Jan 11 2006, 10:59:28)
251  [GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2
252  Type "help", "copyright", "credits" or "license" for more information.
253  >>> from mapnik import *
254  >>>
255
256
257Learning Mapnik
258---------------
259
260Visit https://trac.mapnik.org/wiki/GettingStarted for a basic tutorial on making maps with Mapnik using the Python bindings
261
262Try running the demo scripts in mapnik/demo/python
263
264
265A note on projection support
266----------------------------
267
268Mapnik's core C++ library and map rendering engine support on-the-fly cartographic
269reprojections.
270
271Here is an example on how to use it::
272
273  >>> from mapnik import Projection, Coord
274  >>> p = Projection('+init=epsg:27700') # British National Grid
275  >>> p.forward(Coord(-1.125,51.75))
276  Coord(460396.920899,206113.214203) # reprojected coordinate x, y pair
277  >>> p.forward(Envelope(Coord(-1.125,51.75),Coord(-1.0,50.75)))
278  Envelope(461721.365661,94917.0749406,469024.861457,206224.090767) # reprojected extent
279
280
281The Projection() instance provides inverse() and forward() methods.  For details on the possible parameters,
282see the PROJ.4 documentation.
Note: See TracBrowser for help on using the browser.