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

clang: error: unsupported option '-fopenmp' on Mac OS #3

Open
mmichaelzhang opened this issue Feb 28, 2017 · 16 comments
Open

clang: error: unsupported option '-fopenmp' on Mac OS #3

mmichaelzhang opened this issue Feb 28, 2017 · 16 comments

Comments

@mmichaelzhang
Copy link

Hi there,

I tried to run order "python setup.py build" on Mac OS 10.12.3, and got the error
clang: error: unsupported option '-fopenmp'

I tried export CC=/usr/bin/gcc, gcc-6, clang or llvm-gcc, they all don't work.

for gcc-6 case, I got different error:
gcc-6: error: unrecognized command line option '-Wshorten-64-to-32'

Has anyone encountered the same issue?

Thanks,
Michael

@priyankaMedidata
Copy link

Yes I am facing the same issue. Any resolution found?

@mmichaelzhang
Copy link
Author

So far no good news. I chose to run pypoisson on a linux system, which separated my code into two parts.

Hope you good luck :)

@priyankaMedidata
Copy link

I wanted it for R tool support. So I switched to lower version of R and resolved the issues.

@ernest-tg
Copy link

I just ran into this problem, I will try to find a solution by my own. But if anyone got a solution in the meantime, I am interested :)

@ChenHe-InfoViz
Copy link

find this solved my problem https://daijiang.name/en/2017/06/21/fopenmp-option-of-clang-error/

@Hailey-Liu
Copy link

Same issue.

@patomaki
Copy link

patomaki commented Feb 2, 2020

I just tried to install the package as well from a mac. I managed to install but am still not able to run the examples.

I have previously installed gcc and g++ with homebrew. Then, exporting and aliasing them, as
export CC=/usr/local/bin/gcc-8
export CXX=/usr/local/bin/g++-8
alias gcc=‘/usr/local/bin/gcc-8’
alias g++=‘/usr/local/bin/g++-8’

enables me to succesfully run

python setup.py build
python setup.py install

after modifying the first line of pypoisson.pyx,
#cython: language_level=3str
to
#cython: language_level=3

However, running python test.py halts to the error
Traceback (most recent call last):
File "test.py", line 1, in
from pypoisson import poisson_reconstruction
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/pypoisson.cpython-36m-darwin.so, 2): Symbol not found: _GOMP_parallel
Referenced from: /anaconda3/lib/python3.6/site-packages/pypoisson.cpython-36m-darwin.so
Expected in: flat namespace
in /anaconda3/lib/python3.6/site-packages/pypoisson.cpython-36m-darwin.so

and so far I haven't been able to advance from here.
When it says this has been tried on OSX, I wonder how and what is the environment like?

@mmolero
Copy link
Owner

mmolero commented Feb 2, 2020

I tested 5 years ago so sorry I don’t remember the last exact environment I used.

@patomaki
Copy link

patomaki commented Feb 2, 2020

Thanks for the quick reply!

I actually just gor forward. The issue was solved by changing the line
extra_link_args=["-fopenmp"]
to (in my case, since I'm using gcc version 8)
extra_link_args=["-fopenmp",'-Wl,-rpath,/usr/local/opt/gcc/lib/gcc/8/']
in setup.py (and rebuilding/installing)
This has been mentioned in e.g. lesgourg/class_public#208

(After this, example/test.py yields segmentation fault 11, I'll check out the other issue thread)

@mmolero
Copy link
Owner

mmolero commented Feb 2, 2020

I believe I did with gcc 5.x version.

@patomaki
Copy link

patomaki commented Feb 2, 2020

Thanks for the reply! I was able to install with the above modifications, but for some reason the example segfaults (this does not change when changing e.g. depth in the program, just changes the time it takes before the segfault).

@zehongs
Copy link

zehongs commented Mar 23, 2020

Here's another solution I found (with clang llvm installed):

  • brew install llvm libomp
  • in the setup script,
# Using compiler of clang with llvm installed
os.environ["CC"] = "/usr/local/opt/llvm/bin/clang"
os.environ["CXX"] = "/usr/local/opt/llvm/bin/clang++"
# Add include/link dirs, and modify the stdlib to libc++
exts = [Extension("pypoisson", sources,
                  include_dirs=["/usr/local/opt/llvm/include"],
                  library_dirs=["/usr/local/opt/llvm/lib"],
                  language="c++",
                  extra_compile_args=["-w", "-fopenmp", '-stdlib=libc++'],
                  extra_link_args=["-fopenmp", '-stdlib=libc++']
                  )]

@you6878
Copy link

you6878 commented Nov 14, 2020

@zehongs

I added this your code but It doen't work

In file included from src/PoissonRecon_v6_13/src/PlyFile.cpp:40: In file included from src/PoissonRecon_v6_13/src/Ply.h:220: In file included from src/PoissonRecon_v6_13/src/Geometry.h:390: src/PoissonRecon_v6_13/src/Geometry.inl:342:3: error: use of undeclared identifier 'iter' iter=edgeMap.find(e); ^ src/PoissonRecon_v6_13/src/Geometry.inl:343:6: error: use of undeclared identifier 'iter' if(iter==edgeMap.end())

@r03ert0
Copy link

r03ert0 commented Jan 23, 2021

here's what worked for me (haven't tested yet, but it compiles \o/)

brew reinstall gcc
brew reinstall libomp
export CC=/usr/local/bin/gcc-10
export CXX=/usr/local/bin/g++-10

In the file Geometry.inl I changed this at line 328:

// #ifdef __linux__ 
// 	hash_map<long long,int>::iterator iter;
// #elif _WIN32
// 	std::map<long long, int>::iterator iter;
// #endif
std::map<long long, int>::iterator iter;

In the file Geometry.h I added this at line 41:

#include <stdio.h>

After that, python setup.py build and python setup.py install work fine : )

@r03ert0
Copy link

r03ert0 commented Jan 23, 2021

...too bad, python test.py fails with Segmentation fault: 11

@bhatiaharsh
Copy link
Contributor

there are several issues here.

  1. the code requires a compiler that supports -fopenmp. natively available clang does not.

    • you can either use a gcc compiler that supports -fopenmp -- you need to specify CC=<path_to_gcc> CXX=<path_to_g++> python setup.py build (simply passing CC will not work).
    • or you can use @zehongs's solution to install libomp on mac.
  2. @you6878 's issue of not finding the right headers is because the code needs an additional macro. @r03ert0 's solution works but is not a great idea because it breaks the code on window. you should pass the __linux__ macro. see here.

  3. Finally, the segfault that @r03ert0 and @patomaki reported may be related to this

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