源码安装部署:https://github.com/mapnik/mapnik/blob/master/INSTALL.md
安装相关的依赖,自己安装部署的过程中发现几个问题,是因为两个依赖没有安装好:
1.boost
https://www.boost.org/users/download/
boost安装前要先删除旧版本,一般安装在/usr目录下,把这里相关的boost文件删除即可。
安装的版本是1.69.0
./bootstrap.sh
./b2
成功即提示:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/root/mapbox_tools/boost_1_69_0
The following directory should be added to linker library paths:
/root/mapbox_tools/boost_1_69_0/stage/lib
./b2 install --prefix=/usr
##--prefix=/usr用来指定boost的安装目录,不加此参数的话默认的头文件在/usr/local/include/boost目录下,
库文件在/usr/local/lib/目录下。
这里把安装目录指定为--prefix=/usr则boost会直接安装到系统头文件目录和库文件目录下,可以省略配置环境变量。
2.mabox variant
https://github.com/mapbox/variant
需要使用到这里面的头文件,不需要编译安装,直接把这个/variant-1.1.3/include/下的mapbox文件夹拷贝到操作系统的/usr/include文件夹里面即可。
3.其他依赖:
cairo-1.16.0.tar.xz
libwebp-1.1.0.tar.gz
proj-4
sqlite-autoconf-3330000.tar.gz(源码安装完毕,它自动配置一些东西,导致gdal出问题,删除了它就可以)
tiff-4.1.0.tar.gz
mapnik-3.0.23 安装过程
第一次安装到这个位置:
./configure PREFIX=/pgs/usr/local/mapnik
重装到这个位置:
./configure PREFIX=/opt/mapnik
make
make install
因为安装在自定义路径,需要配置bin 、include、 lib的路径:
ln -s /opt/mapnik/include/mapnik/ /usr/local/include/
ln -s /opt/mapnik/bin/* /usr/local/bin/
ln -s /opt/mapnik/lib/* /usr/local/lib/
测试:
mapnik-config
mapnik-index
mapnik-render
如果安装到默认位置,会遇到一些错误:
以前安装完毕,如果需要重新安装,必须要
make clean
./configure
成功的话,提示:
(看最后的附件)
make
make install
出现四个类似错误:
Install file: "utils/mapnik-index/mapnik-index" as "/usr/local/bin/mapnik-index"
Install file: "utils/mapnik-render/mapnik-render" as "/usr/local/bin/mapnik-render"
Install file: "utils/shapeindex/shapeindex" as "/usr/local/bin/shapeindex"
scons: *** [/usr/local/bin/shapeindex] /usr/local/bin/shapeindex: No such file or directory
scons: building terminated because of errors.
Install file: "src/json/libmapnik-json.a" as "/usr/local/lib/libmapnik-json.a"
scons: *** [/usr/local/lib/libmapnik-json.a] /usr/local/lib/libmapnik-json.a: No such file or directory
scons: building terminated because of errors.
make: *** [install] 错误 2
要手动添加以下软连接
ln -s /root/mapbox_tools/mapnik-3.0.23/src/json/libmapnik-json.a /usr/local/lib/
ln -s /root/mapbox_tools/mapnik-3.0.23/src/wkt/libmapnik-wkt.a /usr/local/lib/
ln -s /root/mapbox_tools/mapnik-3.0.23/src/libmapnik.so /usr/local/lib/libmapnik.so.3.0.23
ln -s /root/mapbox_tools/mapnik-3.0.23/utils/shapeindex/shapeindex /usr/local/bin/
直接测试(不用配置,因为是默认安装路径/usr/local/):
mapnik-config
mapnik-render
mapnik-index
python-mapnik-3.0.16 安装过程
参考:https://github.com/mapnik/python-mapnik
出现错误:https://github.com/mapnik/python-mapnik/issues/223
解决方法:https://github.com/mapnik/python-mapnik/commit/7da019cf9eb12af8f8aa88b7d75789dfcd1e901b
python setup.py develop
成功即提示:
c++ -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/src/mapnik_color.o
build/temp.linux-x86_64-2.7/src/mapnik_coord.o build/temp.linux-x86_64-2.7/src/mapnik_datasource.o
build/temp.linux-x86_64-2.7/src/mapnik_datasource_cache.o
build/temp.linux-x86_64-2.7/src/mapnik_envelope.o
build/temp.linux-x86_64-2.7/src/mapnik_expression.o
build/temp.linux-x86_64-2.7/src/mapnik_feature.o
build/temp.linux-x86_64-2.7/src/mapnik_featureset.o
build/temp.linux-x86_64-2.7/src/mapnik_font_engine.o
build/temp.linux-x86_64-2.7/src/mapnik_fontset.o
build/temp.linux-x86_64-2.7/src/mapnik_gamma_method.o
build/temp.linux-x86_64-2.7/src/mapnik_geometry.o
build/temp.linux-x86_64-2.7/src/mapnik_grid.o
build/temp.linux-x86_64-2.7/src/mapnik_grid_view.o
build/temp.linux-x86_64-2.7/src/mapnik_image.o
build/temp.linux-x86_64-2.7/src/mapnik_image_view.o
build/temp.linux-x86_64-2.7/src/mapnik_label_collision_detector.o
build/temp.linux-x86_64-2.7/src/mapnik_layer.o
build/temp.linux-x86_64-2.7/src/mapnik_logger.o
build/temp.linux-x86_64-2.7/src/mapnik_map.o
build/temp.linux-x86_64-2.7/src/mapnik_palette.o
build/temp.linux-x86_64-2.7/src/mapnik_parameters.o
build/temp.linux-x86_64-2.7/src/mapnik_proj_transform.o
build/temp.linux-x86_64-2.7/src/mapnik_projection.o
build/temp.linux-x86_64-2.7/src/mapnik_python.o
build/temp.linux-x86_64-2.7/src/mapnik_query.o
build/temp.linux-x86_64-2.7/src/mapnik_raster_colorizer.o
build/temp.linux-x86_64-2.7/src/mapnik_rule.o
build/temp.linux-x86_64-2.7/src/mapnik_scaling_method.o
build/temp.linux-x86_64-2.7/src/mapnik_style.o
build/temp.linux-x86_64-2.7/src/mapnik_symbolizer.o
build/temp.linux-x86_64-2.7/src/mapnik_view_transform.o
build/temp.linux-x86_64-2.7/src/python_grid_utils.o -L/usr/lib64 -lpython2.7 -o
build/lib.linux-x86_64-2.7/mapnik/_mapnik.so
-L/usr/local/lib -lmapnik -L/pgs/usr/local/pgsql/lib
-L/usr/local/lib -L/usr/lib -pthread -lboost_filesystem
-lboost_regex -lcairo -lpng -lproj -ltiff -lwebp -licui18n
-lboost_system -lharfbuzz -ljpeg -licuuc -lfreetype -lz -ldl
-lmapnik-wkt -lmapnik-json -lboost_python -lboost_thread
-lboost_system -lrt -Wl,-z,origin -Wl,-rpath=$ORIGIN/lib
copying
build/lib.linux-x86_64-2.7/mapnik/_mapnik.so -> mapnik
Creating /usr/lib64/python2.7/site-packages/mapnik.egg-link (link to .)
Adding mapnik 3.0.23 to easy-install.pth file
Installed /root/mapbox_tools/python-mapnik-3.0.16
Processing dependencies for mapnik==3.0.23
Finished processing dependencies for mapnik==3.0.23
python setup.py install
成功即提示:
……
zip_safe flag not set; analyzing archive contents...
mapnik.__init__: module references __file__
mapnik.mapnik_settings: module references __file__
creating dist
creating 'dist/mapnik-3.0.23-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing mapnik-3.0.23-py2.7-linux-x86_64.egg
creating /usr/lib64/python2.7/site-packages/mapnik-3.0.23-py2.7-linux-x86_64.egg
Extracting mapnik-3.0.23-py2.7-linux-x86_64.egg to /usr/lib64/python2.7/site-packages
Removing mapnik 3.0.23 from easy-install.pth file
Adding mapnik 3.0.23 to easy-install.pth file
Installed /usr/lib64/python2.7/site-packages/mapnik-3.0.23-py2.7-linux-x86_64.egg
Processing dependencies for mapnik==3.0.23
Finished processing dependencies for mapnik==3.0.23
附件:mapnik 3.0.23 ./configure成功的提示:
scons: Reading SConscript files ...
Welcome to Mapnik...
Configuring build environment...
SCons CONFIG found: 'config.py', variables will be inherited...
Configuring on Linux in *release mode*...
Checking for freetype-config... yes
Checking for dlfcn.h support ... yes
Checking if compiler (c++) supports -std=c++11 flag... (cached) yes
Checking for C library z... yes
Checking for C++ library icuuc... yes
Checking for ICU version >= 4.2... found: icu 50.1
(cached) Checking for C++ library harfbuzz... yes
Checking for HarfBuzz version >= 0.9.34... found: HarfBuzz 1.7.5
Checking for HarfBuzz with freetype support
(cached) yes
Searching for boost libs and headers... (cached)
Found boost libs: /usr/local/lib
Found boost headers: /usr/local/include
Checking for C++ header file boost/version.hpp... yes
Checking for Boost version >= 1.47... yes
Found boost lib version... 1_69
Checking for C++ library boost_system... yes
Checking for C++ library boost_filesystem... yes
Checking for C++ library boost_regex... yes
Checking for C++ library boost_program_options... yes
Checking whether Boost was compiled with C++11 scoped enums ... yes
Checking if boost_regex was built with ICU unicode support... (cached) yes
Checking for C library jpeg... yes
Checking for C library proj... yes
Checking for C library png... yes
Checking for C library webp... yes
Checking for C library tiff... yes
Checking for PROJ_LIB directory...pj_open_lib returned /usr/local/share/proj/
Checking for ICU data directory...icu-config returned /usr/share/icu/50.1.2
Checking for GDAL data directory...GDAL_PREFIX returned /usr/local/share/gdal
Checking for pkg-config... yes
Checking for requested plugins dependencies...
Checking for gdal-config --libs... yes
Checking for gdal-config --cflags... yes
Checking for name of gdal library... yes
Checking for C++ library gdal... yes
Checking if gdal is ogr enabled... yes
Checking for gdal-config --libs... yes
Checking for gdal-config --cflags... yes
Checking for name of ogr library... yes
Checking for C++ library gdal... yes
Checking for pg_config... yes
Checking for pg_config... yes
Checking for C library sqlite3... yes
Checking if SQLite supports RTREE... (cached) yes
Checking for cairo... yes
Checking for cairo lib and include paths... yes
Checking for cairo freetype font support ... yes
All Required dependencies found!
Overwriting and re-saving file 'config.py'...
Will hold custom path variables from commandline and python config file(s)...
Configure completed: run `make` to build or `make install`
但是在python中,运行mapnik出现错误:
~ python
> import mapnik
段错误(吐核)
在虚拟环境下,也出现错误
cd 某目录
pipenv run python "import mapnik";
出现no such file
把/usr/lib64/python2.7/site-packages/目录中的mapnik 拷贝到
虚拟环境
/root/.local/share/virtualenvs/某目录-hash/lib64/python2.7/site-packages/下面
仍然出现
段错误(吐核)