CentOS7下編譯安裝Mapnik

來源:互聯網
上載者:User

CentOS7下編譯安裝Mapnik

下載mapnik,我選用的是Master的版本,Master版本需要glibc2.14+的支援,這個需要注意一下。

InstallationTroubleshooting 編譯安裝遇到問題匯總

git clone https://github.com/mapnik/mapnik.git

安裝必要的依賴

yum install boost-devel postgresql-devel proj-devel proj-epsg

擴充需要的依賴

yum install sqlite-devel libpng-devel libtiff-devel libjpeg-devel libicu-devel

編譯的時候,官方需求最少要有5GB(for g++)的記憶體,對於小記憶體的使用者(我當時只有2G)可能會出現記憶體不夠而異常退出的情況,如果出現以下狀況而退出的話:

g++: internal compiler error: Killed (program cc1plus)

我們可以臨時增加磁碟交換空間來臨時解決該問題

sudo dd if=/dev/zero of=/swapfile bs=64M count=16  sudo mkswap /swapfile  sudo swapon /swapfile  

然後在編譯完成後,在恢複到之前的狀態

sudo swapoff /swapfile  sudo rm /swapfile  

開始編譯

./configure make make install

中間會出現錯誤如:

編譯一下harfbuzz 參照如下修改

Harfbuzz not found

$ brew install harfbuzz...$ ./configure...Checking for C++ library harfbuzz... noCould not find required header or shared library for harfbuzz...Exiting... the following required dependencies were not found: - harfbuzz (HarfBuzz text shaping library | configure with HB_LIBS & HB_INCLUDES)

Solution:HB_LIBS and HB_INCLUDES are directories, not cflags/ldflags, and HB_INCLUDES needs not to include the “harfbuzz” directory itself. If pkg-config says:

$ pkg-config --libs --cflags harfbuzz-I/usr/local/Cellar/harfbuzz/0.9.35_1/include/harfbuzz -L/usr/local/Cellar/harfbuzz/0.9.35_1/lib -lharfbuzz

what you actually need is修改設定檔為,直接指定HB_LIBS,HB_INCLUDES

$ ./configure HB_LIBS=/usr/local/Cellar/harfbuzz/0.9.35_1/lib HB_INCLUDES=/usr/local/Cellar/harfbuzz/0.9.35_1/include

簡單測試

python import mapnik

如果出現類似的錯誤

ImportError: libmapnik.so.3.0: cannot open shared object file: No such file or directory

需要手工添加一下so的位置

vim /etc/ld.so.conf.d/mapnik-x86_64.conf

添加一行內容:/usr/local/lib

然後儲存退出,同時執行一下

ldconfig

如果沒有問題的話可以試一下渲染demo,會產生一些不同品質不同格式的圖片demo檔案

python demo/python/rundemo.py

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.