【问题标题】:mapnik install fail on Red Hat Linux在 Red Hat Linux 上安装 mapnik 失败
【发布时间】:2012-09-14 15:28:36
【问题描述】:

我只是想将 Python 绑定到安装在 Red Hat Enterprise 机器上的 Mapnik 2.1 并在 Sage (sagemath.org) 中使用它们。这是我不能使用 yum 的公司机器,所以一直都是 tarball,宝贝。

我已经解决了安装依赖项和制定每个配置所需的语法的许多问题。每次我解决一个问题,就会有另一个问题。目前我无法通过 mapnik 配置来查看 libboost_system.so,它肯定在 /usr/local/lib 中,并且有一个从 /usr/lib 指向它的符号链接。

详情:

Red Hat Enterprise system:
> more /proc/version
Linux version 2.6.18-92.el5PAE (brewbuilder@hs20-bc2-3.build.redhat.com) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-41)) 
used install directions at github.com/mapnik/mapnik/blob/master/INSTALL.md, github.com/mapnik/mapnik/wiki/Mapnik2 and elsewhere
installed proj 4.8 from tarball using several solutions provided on the web to fix install problems
installed icu4c-4_6 from tarball to /usr/local/...
installed boost 1.51 from tarball pointing to the newly installed icu:
download boost_1_51_0.tar.gz
tar ...
cd boost_1_51_0
./bootstrap.sh

(之前我直接使用 ./b2 来安装所有 boost - 使用上面的网页说明返回以这种方式重新安装 boost 的一部分:)

sudo ./b2 --with-thread --with-filesystem --with-iostreams --with-python --with-regex -sHAVE_ICU=1 -sICU_PATH=/usr/local/lib --with-program_options --with-system link=shared toolset=gcc stage
sudo ./b2 --with-thread --with-filesystem --with-iostreams --with-python --with-regex -sHAVE_ICU=1 -sICU_PATH=/usr/local/lib --with-program_options --with-system link=shared toolset=gcc install
sudo /sbin/ldconfig

现在尝试安装 mapnik:

download mapnik-v2.1.0.tar.bz2
tar ...
cd ...
./configure PYTHON=/opt/sage-5.2/local/bin/python ICU_LIBS=/usr/local/lib ICU_INCLUDES=/usr/local/include BOOST_INCLUDES=/usr/local/include/boost BOOST_LIBS=/usr/local/lib

./configure PYTHON=/opt/sage-5.2/local/bin/python ICU_LIBS=/usr/local/lib ICU_INCLUDES=/usr/local/include

./configure PYTHON=/opt/sage-5.2/local/bin/python

(相同的结果)

"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 xml2-config... yes
Sorting lib and inc compiler paths...(cached) yes
Checking for C library m... yes
Checking for C library ltdl... yes
Checking for C library png... yes
Checking for C library tiff... yes
Checking for C library z... yes
Checking for C library proj... yes
Checking for C++ library icuuc... yes
Checking for C library jpeg... yes
Checking for ICU version >= 4.2... found: icu 4.6
(cached) Searching for boost libs and headers... (cached)
  *libs found: /usr/local/lib
  *headers found: /usr/local/include
  *no lib naming extension found
Checking for Boost version >= 1.47... yes
Found boost lib version... 1_51
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 for C++ library boost_thread... yes
.sconf_temp/conftest_18: error while loading shared libraries: libboost_system.so.1.51.0: 
cannot open shared object file: No such file or directory
Checking if boost_regex was built with ICU unicode support... (cached) no
Checking for requested plugins dependencies...
Checking for gdal-config --libs... yes
Checking for gdal-config --cflags... yes
Checking for name of gdal library... gdal
Checking if gdal is ogr enabled... yes
Checking for name of ogr library... gdal
Checking for C library curl... no
Checking for pg_config... error: no result no
Checking for C library sqlite3... no
Checking if SQLite supports RTREE... (cached) no
Checking for pkg-config... yes
Checking for cairo... no
Checking for C++ header file boost/python/detail/config.hpp... yes
Checking for pkg-config... yes
Checking for pycairo... no
All Required dependencies found!
Overwriting and re-saving file 'config.py'...
Will hold custom path variables from commandline and python config file(s)...

注意:将在没有这些可选依赖项的情况下构建:

  • boost_regex_icu(mapnik 中的 unicode regex 支持需要使用可选 ICU unicode 支持构建的 libboost_regex。)

  • curl(“osm”插件需要 libcurl - 更多信息:https://github.com/mapnik/mapnik/wiki//OsmPlugin

  • pg_config(pg_config 程序 | 尝试设置 PG_CONFIG SCons 选项)

  • sqlite3(SQLite3 C 库 | 使用 SQLITE_LIBS 和 SQLITE_INCLUDES 配置 | 更多信息:https://github.com/mapnik/mapnik/wiki//SQLite

  • sqlite_rtree(SQLite 插件需要构建支持 RTREE 的 libsqlite3 (-DSQLITE_ENABLE_RTREE=1))

  • cairo(Cairo C 库 | 使用 pkg-config 配置 | 尝试设置 PKG_CONFIG_PATH SCons 选项)

  • pycairo(Python 绑定到 Cairo 库 | 使用 pkg-config 配置 | 尝试设置 PKG_CONFIG_PATH SCons 选项)

    .sconf_temp/conftest_33:加载共享库时出错:libboost_system.so.1.51.0:无法打开共享对象文件:没有这样的文件或目录 解析mapnik版本遇到问题,回退到2.1.0 检查 C 头文件 Python.h... 是 绑定 Python 版本... 2.7 Python 2.7 前缀... /opt/sage-5.2/local Python 绑定将安装在... /opt/sage-5.2/local/lib/python2.7/site-packages 配置完成:运行make 构建或make install" 制作 “…… /usr/bin/ld: 找不到 -lsqlite3 collect2:错误:ld 返回 1 个退出状态 scons: * [tests/cpp_tests/csv_parse_test-bin] 错误 1 scons:建筑因错误而终止。 制作:* [mapnik] 错误 2"

但我认为 sqlite3 是可选的 ...

我认为 sqlite3 问题可能是一个红鲱鱼。前面的问题是configure阶段没有找到boost_thread。我的系统显示:

ls -l /usr/local/lib/libboost_system.so*
lrwxrwxrwx 1 root root    25 Sep 11 17:40 /usr/local/lib/libboost_system.so -> libboost_system.so.1.51.0
-rwxr-xr-x 1 root root 16898 Sep 11 17:40 /usr/local/lib/libboost_system.so.1.51.0
ldd /usr/local/lib/libboost_system.so.1.51.0
        linux-gate.so.1 =>  (0x005c1000)
        librt.so.1 => /lib/librt.so.1 (0x00cd9000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x002f4000)
        libm.so.6 => /lib/libm.so.6 (0x009e1000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00f82000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00a6a000)
        libc.so.6 => /lib/libc.so.6 (0x00110000)
        /lib/ld-linux.so.2 (0x0050d000)

所以它确实存在并且有效。

为了安全起见(没有帮助)添加了一个符号链接:

ls -l /usr/lib/libboost_system.so
lrwxrwxrwx 1 root root 33 Sep 14 10:16 /usr/lib/libboost_system.so -> /usr/local/lib/libboost_system.so

这很奇怪,因为在同一位置可以找到其他库。此外,配置阶段在“搜索提升库和标头...找到的库:/usr/local/lib”错误之前声明了几行

在这一点上,我真的不相信 scons。我遇到了另一个问题,mapnik 配置阶段找不到库 (libproj)。后来又说boost的版本至少不是1.48。一旦我添加了指向 proj .so 文件的正确符号链接,关于 boost 版本的配置错误就消失了。所以我坚持一般规则,即您应该专注于发现的第一个错误并解决那个错误。

请注意,Python 的非标准位置 (PYTHON=/opt/sage-5.2/local/bin/python) 似乎没问题。

查看 mapnik 日志文件 config.log,但没有看到其他信息。检查了网络和 github.com/mapnik/mapnik/wiki/InstallationTroubleshooting 但没有任何相关。很抱歉这篇文章很长,但细节很重要。感谢阅读。

另一个线索可能是:

Checking if boost_regex was built with ICU unicode support... (cached) no

即使上面表明这是正确完成的(?)。

【问题讨论】:

  • 为什么投反对票?这是一篇很有帮助的帖子。

标签: boost makefile configure mapnik


【解决方案1】:

Burningbright,

Mapnik 用户列表将是一个更好的地方。

无论如何,我认为问题在于您尚未配置系统以在 /usr/local/lib 中查找库。您需要执行 export LD_LIBRARY_PATH=/usr/local/lib 或者您需要在运行 ldconfig 之前将 /usr/local/lib 添加到您的 /etc/ld.so.conf/ 中。

可能会混淆的小问题:1)您的 BOOST_INCLUDES 选项错误,应该是 BOOST_INCLUDES=/usr/local/include/ 而不是 BOOST_INCLUDES=/usr/local/include/boost。 2) 我真的不推荐符号链接到/usr/lib - 这可能会破坏事情是奇怪的方式

此外,尽管在配置过程中出现链接错误,但我认为您总体上还可以。与测试的链接错误没什么大不了的,很可能我们需要将其设为可选。我认为构建过程中唯一的主要问题是提升链接,这应该可以按照上述解决。

【讨论】:

  • 参见gist.github.com/3427021 的第64 行,了解我将/usr/local/lib 添加到系统库搜索路径的方式。
  • 感谢协助。我考虑过修改/etc/ld.so.conf,但我不应该在这个盒子上碰它,因为我不是IT。添加符号链接只会影响我的东西,不会影响其他人。但是,由于没有其他工作,我可以验证将 /usr/local/lib 添加到 ld.so.conf 是否有效! (那如果我丢了工作怎么办)。我仍然不太明白这个问题,因为 mapnik 日志文件显示 /usr/local/lib 正在被搜索,并且其他需要位于同一位置的库的 mapnik 依赖项都可以,但无论如何都可以。
  • 不幸的是,运行 make 我仍然得到... g++ -o tests/cpp_tests/csv_parse_test-bin tests/cpp_tests/csv_parse_test.o plugins/input/csv/csv_datasource.o -Ldeps/agg -Lsrc -L/usr/local/lib -L/usr/lib -lagg -lfreetype -lltdl -lpng -ltiff -lz -lproj -licuuc -lboost_filesystem -lboost_system -lboost_regex -ljpeg -lxml2 -lboost_thread -lmapnik -lsqlite3 /usr /bin/ld: 找不到 -lsqlite3 collect2: 错误: ld 返回 1 退出状态 scons: *** [tests/cpp_tests/csv_parse_test-bin] 错误 1 ​​scons: 构建因错误而终止。 make: *** [mapnik] 错误 2 所以它又开始工作了。
  • 我执行了更多不好的做法来解决 sqlite3 问题,即使配置阶段声明它不包含 sqlite3。放入 libsqlite3.so.0 和 sqlite3.h,现在“make”运行完成。 “sudo make install”运行正常。但现在在 sage python 中,“import mapnik”会在“from _mapnik import *”处炸毁——找不到 libmapnik.so.2.1。
  • 这可能是因为链接到 lpython 的 libboost python 无法正常工作。这可能是因为您使用了不同的 python 来提升链接到的内容?
【解决方案2】:

我和你有同样的问题,我看到here那个

export LD_LIBRARY_PATH=/XXX/lib 

会起作用的。

我试过了,它对我有用,但我仍然不确定根本原因是什么。

【讨论】:

    【解决方案3】:

    在 Centos 7 上构建 Mapnik 遇到了同样的问题。 Scon 给出了关于缺少实际存在的库的误导性错误。

    发出简单的

    export LD_LIBRARY_PATH=/usr/local/lib
    

    修复了所有问题。

    应该是对 Centos / RHEL 上许多构建的修复,不仅仅是 Mapnik。

    【讨论】: