pmneila / PyMaxflow

Python library for creating flow networks and computing the maxflow/mincut (aka graph-cuts for Python)
http://pmneila.github.io/PyMaxflow/
243 stars 59 forks source link

`import maxflow` fails on python2.7.8 on conda env on Mac OS X #13

Closed ProGM closed 9 years ago

ProGM commented 9 years ago

After installing conda I tried to install PyMaxflow in his local env:

$ python -V
Python 2.7.8 :: Continuum Analytics, Inc.
$ which python
/Users/progm/anaconda/bin/python
$ conda install cython
...
$ git clone https://github.com/pmneila/PyMaxflow
$ cd PyMaxflow
$ python setup.py install
...
ok

But when I run python and I try to import maxflow I receive this error:

[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import maxflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/progm/anaconda/lib/python2.7/site-packages/maxflow/__init__.py", line 37, in <module>
    import _maxflow
ImportError: dlopen(/Users/progm/anaconda/lib/python2.7/site-packages/maxflow/_maxflow.so, 2): Symbol not found: __ZNSs4_Rep20_S_empty_rep_storageE
  Referenced from: /Users/progm/anaconda/lib/python2.7/site-packages/maxflow/_maxflow.so
  Expected in: dynamic lookup

>>> 

This is not happening if I use builtin Mac OS X python 2.7.6.
Any idea?

pmneila commented 9 years ago

Hi.

It looks like it is not linking to libstdc++. Try compiling with LDFLAGS=-lstdc++:

$ rm -r build/
$ LDFLAGS=-lstdc++ python setup.py build
$ python setup.py install

Let me know if it works.

ProGM commented 9 years ago

Oh, quite simple. It's working! Thank you :)