Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execution on OSX 10.12.2 #11

Closed
jtlz2 opened this issue Mar 27, 2017 · 13 comments
Closed

execution on OSX 10.12.2 #11

jtlz2 opened this issue Mar 27, 2017 · 13 comments

Comments

@jtlz2
Copy link

jtlz2 commented Mar 27, 2017

@darafferty After a successful build and root install on a Mac, python -c 'import bdsf' throws the following:

Traceback (most recent call last):
File "", line 1, in
File "bdsf/init.py", line 19, in
from collapse import Op_collapse
File "bdsf/collapse.py", line 10, in
import _cbdsm
ImportError: dlopen(bdsf/_cbdsm.so, 2): Symbol not found: __ZN5boost6python7objects15function_objectERKNS1_11py_functionERKSt4pairIPKNS0_6detail7keywordES9_E
Referenced from: /Users/myname/src/PyBDSF/build/lib.macosx-10.6-x86_64-2.7/bdsf/_cbdsm.so
Expected in: flat namespace
in /Users/jtlz2/src/PyBDSF/build/lib.macosx-10.6-x86_64-2.7/bdsf/_cbdsm.so

Is this just a name mangling issue? I can't see where to put a -stdlib=libstdc++ (if it is that).

Let me know if you need any more info. Thanks!

@tammojan
Copy link
Collaborator

You could alter setup.py by adding extra_link_args and extra_compile_args to the extensions.
I have not been able to install pybdsf on a mac yet, so if you have success please report back!

@jtlz2
Copy link
Author

jtlz2 commented Mar 27, 2017

@tammojan -stdlib=libstdc++ didn't work via that route.

An issue with my boost compilation?

@tammojan
Copy link
Collaborator

When compiling boost, was libc++ or libstdc++ used?

@jtlz2
Copy link
Author

jtlz2 commented Mar 27, 2017

Is there an easy way to find out? :\

@tammojan
Copy link
Collaborator

On my machine (10.12.3, where I installed boost-python with homebrew), it's using libc++:

/usr/local/lib$ otool -L /usr/local/lib/libboost_python.dylib
libboost_python.dylib:
	/usr/local/opt/boost-python/lib/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

@jtlz2
Copy link
Author

jtlz2 commented Mar 27, 2017

Ditto:

/usr/local/lib/libboost_python.dylib:
/usr/local/opt/boost-python/lib/libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.4.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

@jtlz2
Copy link
Author

jtlz2 commented Mar 27, 2017

 extra_link_args=["-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7"],
 extra_compile_args=["-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7"]

fixes the boost error, but now there's a gfortran error:

Traceback (most recent call last):
File "", line 1, in
File "bdsf/init.py", line 19, in
from collapse import Op_collapse
File "bdsf/collapse.py", line 10, in
import _cbdsm
ImportError: dlopen(bdsf/_cbdsm.so, 2): Symbol not found: __gfortran_stop_numeric_f08
Referenced from: /Users/jtlz2/src/PyBDSF/build/lib.macosx-10.6-x86_64-2.7/bdsf/_cbdsm.so
Expected in: flat namespace
in /Users/jtlz2/src/PyBDSF/build/lib.macosx-10.6-x86_64-2.7/bdsf/_cbdsm.so

@darafferty
Copy link
Collaborator

I have it working on 10.12.3, but I didn't use homebrew (I used anaconda to install boost and got gfortran from https://gcc.gnu.org/wiki/GFortranBinaries). I also had to alter setup.py as follows:

--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ def find_boost():
             boost_python = "boost_python"
     elif system == 'Darwin':
         if sys.version_info[0] == 2:
-            boost_python = "boost_python-mt"
+            boost_python = "boost_python"
         else:
             boost_python = "boost_python3-mt"
     return boost_python
@@ -65,8 +65,8 @@ extensions.append(Extension(
              "src/c++/stat.cc",
              "src/c++/num_util/num_util.cpp"],
      libraries=['minpack', 'port3', 'gfortran', boost_python],
-     include_dirs=["src/c++"],
-     library_dirs=[join(srcpath,"minpack"), join(srcpath,"port3")]
+     include_dirs=["src/c++", '/anaconda/include'],
+     library_dirs=[join(srcpath,"minpack"), join(srcpath,"port3"), '/anaconda/lib/', '/usr/local/gfortran/lib/']
      ))

@jtlz2
Copy link
Author

jtlz2 commented Mar 27, 2017

@tammojan @darafferty You both beat me to it, but I also now have it working (ugly I know - sensitive to version of gfortran):

 boost_python = "boost_python"

...

 library_dirs=["/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6",join(srcpath,"minpack"), join(srcpath,"port3")],
 extra_link_args=["-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7"],extra_compile_args=["-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.7"]

Thanks both

@jtlz2 jtlz2 closed this as completed Mar 27, 2017
@mattia-vaccari
Copy link

I went through all of the above suggestions as closely as possible (modulo my using macports in /opt/local for my software) but still get the following missing symbol error at start-up.

ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bdsf-1.8.9-py2.7-macosx-10.10-x86_64.egg/bdsf/_cbdsm.so, 2): Symbol not found: __ZNSt8ios_base4InitD1Ev
Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bdsf-1.8.9-py2.7-macosx-10.10-x86_64.egg/bdsf/_cbdsm.so
Expected in: flat namespace
in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/bdsf-1.8.9-py2.7-macosx-10.10-x86_64.egg/bdsf/_cbdsm.so

where the ios_base issue (upon some googling) seems to be related to libstdc++

any thoughts?

@tammojan
Copy link
Collaborator

tammojan commented Jun 8, 2017

On OSX, the best way seems to be to use libc++ instead of libstdc++. Could you check to which of those boost-python links?

@tammojan
Copy link
Collaborator

tammojan commented Jun 8, 2017

If necessary, you can build your own boost-python, casacore/casacore#596 (comment)

darafferty pushed a commit that referenced this issue May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants