Question

I'm not having much success when attempting building pgmagick on OS X Lion with XCode 4.3.1.

I've installed both ImageMagick and GraphicsMagick, along side boost, using the following commands (via homebrew):

$ brew install graphicsmagick --with-magick-plus-plus
$ brew install imagemagick --with-magick-plus-plus
$ brew install boost --with-thread-unsafe

then I'm cloning the repo at https://bitbucket.org/hhatto/pgmagick:

$ hg clone https://bitbucket.org/hhatto/pgmagick/src
$ cd pgmagick
$ python setup.py build

However I always receive the following error:

ld: library not found for -lboost_python
collect2: ld returned 1 exit status

Based on the output on stdout, setup is looking in the right place for the boost (/usr/local/lib).

I've also tried easy_install and pip but with no luck. I'm using Pythonbrew but have also disabled this and tried using the stock python install -- still no success.

Any suggestions on how I can fix the problem, or further diagnose the issue?

Was it helpful?

Solution

According to my own reproduction of this issue in brew 0.9 and OSX 10.6.8, the problem is --with-thread-unsafe isn't being honored by the current brew formula file. You can verify this by checking the formula with brew edit boost and seeing if the option appears within the contents of the formula.

Because of this, libboost_python-mt.a and libboost_python-mt.dylib are being built instead of libboost_python.a and libboost_python.dylib.

The easiest ways to fix this are to edit your pgmagick setup.py to replace boost_lib="boost_python" with boost_lib="boost_python-mt" (as pointed out here) or to follow the instructions and patch here. It's otherwise a known issue.

OTHER TIPS

The boost_python lib inside /usr/local/lib/ is named after libboost_python-mt.a and libboost_python-mt.dylib, since the default compiling is w/ multi-threads supporting enabled.

Grep boost_lib="boost_python" under ELSE condition in setup.py and replace it w/ boost_lib="boost_python-mt", will fix the "not found" issue.

Also it's OK to ln "-mt" version to libboost_python.a: as described here for linux boost which no longer appends '-mt' suffix since 1.42.

Ignore this line or you could "with-boost-python=boost_python-mt python setup.py install". You could probably append '--with-boost-python=boost_python-mt' to extra_compile_args inside setup.py, to achieve the same goal.

Furthermore, you could install pgmagick through pip in managed envs. Refs http://rohanradio.com/blog/2011/12/02/installing-pgmagick-on-os-x/

Note that as of July 2014 the boost Python library is a separate homebrew package called boost-python.

5254f8f510fb30484f8fac8be3d38e388a4392e2
Author: Tim D. Smith <git@tim-smith.us>
Date:   Sat Jul 19 15:37:25 2014 -0700

    Split out Boost.Python

You need to install it separately to get the libboost_python shared library.

Does setting DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib in the environment help before the build

e.g

$ export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib
$ hg clone https://bitbucket.org/hhatto/pgmagick/src
$ cd pgmagick
$ python setup.py build

I've submitted a pull request to homebrew to build Boost with both mt and non mt (threaded and thread unsafe) binaries which are required to build pgmagick.

Turns out this is a rather common problem, until the patch is accepted, you can check out or use my formula for Boost to build pgmagick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top