mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
160 stars 91 forks source link

did not match C++ signature Ubuntu #203

Open am2222 opened 5 years ago

am2222 commented 5 years ago

Hi, I have tried to install python-mapnik on ubunto but faced some issues. I have already tested these versions, 1- Installed last mapnik version from its repo with no problem. 2- installed the latest python-mapnik libaray from repo. (I tried to use v3.0.x branch) but it did not work (it throws 'mapnik/bbox2d.hpp' not found) so I switched to master repo and it worked and it is installed fine.

But when I tried to call 'import mapnik' I faced this error

``
python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/m/python-mapnik/mapnik/__init__.py", line 1071, in <module>
    register_plugins()
  File "/home/m/python-mapnik/mapnik/__init__.py", line 1053, in register_plugins
    DatasourceCache.register_datasources(path)
Boost.Python.ArgumentError: Python argument types in
    DatasourceCache.register_datasources(str)
did not match C++ signature:
    register_datasources(std::string)

``

Is there any way to find the source of this error?

lightmare commented 5 years ago

This happens when python-mapnik bindings (_mapnik.so) is compiled against different C++ STL than the Boost.Python library it uses. Python call DatasourceCache.register_datasources(str) apparently does match C++ signature register_datasources(std::string); problem is that the std::string class in python-mapnik is unrelated to the std::string class that Boost.Python has builtin converter for.

If you're linking with dynamic libraries, you can check whether they match with ldd:

$ ldd bindings/python/mapnik/_mapnik.so | grep -Fe c++ -e boost
    libboost_python-py27.so.1.65.1 => /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1 (0x00007f0dda221000)
    libboost_thread.so.1.65.1 => /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.65.1 (0x00007f0dd9ffc000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0dd9c73000)
    libboost_system.so.1.65.1 => /usr/lib/x86_64-linux-gnu/libboost_system.so.1.65.1 (0x00007f0dd8ea8000)

$ ldd /usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.65.1 | grep -Fe c++ -e boost
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f4f10b77000)

If you're building python-mapnik with libraries from Mason, there's a quirk in setup.py that it looks for shared boost libraries even though Mason provides static libraries, and you may end up with the wrong mix linked in. You can check what it finds with python setup.py whichboost, and if that's wrong, override with export BOOST_PYTHON_LIB=boost_python before running python setup.py install.

am2222 commented 5 years ago

@lightmare thanks so much, I'll check your solution. it is for a long time that I am struggling with this error.