lesgourg / class_public

Public repository of the Cosmic Linear Anisotropy Solving System (master for the most recent version of the standard code; GW_CLASS to include Cosmic Gravitational Wave Background anisotropies; classnet branch for acceleration with neutral networks; ExoCLASS branch for exotic energy injection; class_matter branch for FFTlog)
230 stars 285 forks source link

MacOS problem with GOMP when trying to import classy in python #349

Closed danielaloni closed 4 years ago

danielaloni commented 4 years ago

Hello,

I'm trying to install class on my mac. After changing the C compiler to gcc-8 (in the Makefile), I was able to compile the code itself. On the other hand when it seems that I have a problem with the python wrapper. I'm getting the following error: ` Python 2.7.16 |Anaconda, Inc.| (default, Sep 24 2019, 16:55:38) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import classy Traceback (most recent call last): File "", line 1, in ImportError: dlopen(/Users/username/.local/lib/python2.7/site-packages/classy.so, 2): Symbol not found: _GOMP_loop_dynamic_next Referenced from: /Users/username/.local/lib/python2.7/site-packages/classy.so Expected in: flat namespace in /Users/username/.local/lib/python2.7/site-packages/classy.so`

My guess is that python call the wrong C compiler but I'm not sure. I tried to follow #208 but it doesn't solve the problem.

Thanks, Daniel

ThomasTram commented 4 years ago

Hi Daniel

It really looks like the same problem as #208 - did you adapt it for gcc-8? Perhaps you can show your modifications to setup.py?

Cheers, Thomas

danielaloni commented 4 years ago

Hi Thomas,

I tried to modify extra_link_args=['-lgomp']) to both extra_link_args=['-lgomp', '-Wl,-rpath,/usr/local/opt/gcc/lib/gcc/8/']) and extra_link_args=['-lgomp', '-Wl,-rpath,/usr/local/opt/gcc@8/lib/gcc/8/'])

I'm not sure if the later makes sense as I do not fully understand how it works but it was worth trying. In both cases I'm still getting the same error. As I'm not using the default compiler, maybe this rpath is the wrong path, but I'm not sure what do I need to check in order to give the correct one.

Maybe some additional information might help. My default compiler is "clang-1001.0.46.4" and is located at /usr/bin/gcc. My gcc-8 compiler is "Homebrew GCC 8.2.0" and is located at /usr/local/bin/gcc-8. So maybe it helps to understand what should I modify in the solution of #208.

Thanks again, Daniel

ThomasTram commented 4 years ago

Hi Daniel

I am on macOS Catalina 10.15.6 with gcc-9 through Homebrew. The following line works for me:

extra_link_args=['-lgomp', '-Wl,-rpath,/usr/local/opt/gcc/lib/gcc/9/'])

The /usr/local/opt/gcc/lib/gcc/9/ directory contains (among others) the files libgomp.dylib, libgomp.a, libgomp.1.dylib and libgomp.spec. Let me know if that helps!

Cheers, Thomas

danielaloni commented 4 years ago

Hi Thomas,

Sorry for the late response but it took me a while to figure everything out. It was a combination of two errors that made the error. One of them was the one that is solved by your answer, and the other problem was that the MAKEFILE had a path to the wrong python version. Now problem is solved.

Thanks a lot, Daniel

ThomasTram commented 4 years ago

Excellent, I am closing the issue!