mapnik / python-mapnik

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

'python setup.py develop' error (ld: library not found for -lboost_python) #194

Open braunchris opened 6 years ago

braunchris commented 6 years ago

This is similar to #131 but the missing library is different.

Mapnik seems to be installed properly: 'mapnik-config -v' outputs '3.0.20' 'clang --version' : 'Apple LLVM version 9.1.0 (clang-902.0.39.2)' Mac OS X: 10.13.6 (High Sierra) Python 3.7.0

When executing python setup.py develop I get:

ld: library not found for -lboost_python
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'c++' failed with exit status 1

I have XCode installed, and following other posts I also added the following in my bash_profile:

export BOOST_PYTHON_LIB=boost_python
export BOOST_THREAD_LIB=boost_thread
export BOOST_SYSTEM_LIB=boost_system

However it didn't help. Any idea how to solve this problem?

talaj commented 6 years ago

Where do you have boost-python libs installed?

I don't have OS X, but on Debian, for example, I see these files:

$ ls -1 /usr/lib/x86_64-linux-gnu/libboost_python*
/usr/lib/x86_64-linux-gnu/libboost_python.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.a
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so
/usr/lib/x86_64-linux-gnu/libboost_python-py27.so.1.62.0
/usr/lib/x86_64-linux-gnu/libboost_python-py35.a
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so
/usr/lib/x86_64-linux-gnu/libboost_python-py35.so.1.62.0
/usr/lib/x86_64-linux-gnu/libboost_python.so

So I can link with -lboost_python:

$ ld -o /dev/null -lboost_python --verbose 2>/dev/null | grep succeeded
attempt to open //usr/lib/x86_64-linux-gnu/libboost_python.so succeeded

However, on my Gentoo system, I see these files:

$ ls -1 /usr/lib/libboost_python-*
/usr/lib/libboost_python-2.7.a
/usr/lib/libboost_python-2.7-mt.so
/usr/lib/libboost_python-2.7.so
/usr/lib/libboost_python-2.7.so.1.65.0
/usr/lib/libboost_python-3.6.a
/usr/lib/libboost_python-3.6-mt.so
/usr/lib/libboost_python-3.6.so
/usr/lib/libboost_python-3.6.so.1.65.0

And cannot link -lboost_python:

$ ld -o /dev/null -lboost_python --verbose 2>/dev/null  | grep succeeded
FAIL

I have to link -lboost_python-2.7:

$ ld -o /dev/null -lboost_python-2.7 --verbose 2>/dev/null  | grep succeeded
attempt to open /usr/lib64/libboost_python-2.7.so succeeded

Therefore this export should work for me:

export BOOST_PYTHON_LIB=boost_python-2.7
jbonhag commented 5 years ago

Thanks, this was very helpful. I installed Mapnik and boost-python3 on macOS Mojave with Homebrew:

brew install mapnik boost-python3

This symlinked the libs into /usr/local/lib:

/usr/local/lib/libboost_python37.a
/usr/local/lib/libboost_python37.dylib
/usr/local/lib/libboost_python37-mt.a
/usr/local/lib/libboost_python37-mt.dylib

And this export worked:

export BOOST_PYTHON_LIB=boost_python37
am2222 commented 5 years ago

@talaj Hi, Should we build mapnik with the same boost_python version? Does export BOOST_PYTHON_LIB=boost_python3 works when we are building mapnik's main library? or we have to set python path too?