mmolero / pypoisson

Poisson Surface Reconstruction Python Binding
MIT License
242 stars 30 forks source link

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

Open mmichaelzhang opened 7 years ago

mmichaelzhang commented 7 years ago

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 commented 7 years ago

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

mmichaelzhang commented 7 years ago

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 commented 7 years ago

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

ernest-tg commented 7 years ago

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 commented 6 years ago

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

Hailey-Liu commented 5 years ago

Same issue.

patomaki commented 4 years ago

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 commented 4 years ago

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

patomaki commented 4 years ago

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. https://github.com/lesgourg/class_public/issues/208

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

mmolero commented 4 years ago

I believe I did with gcc 5.x version.

patomaki commented 4 years ago

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 commented 4 years ago

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

you6878 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

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

bhatiaharsh commented 3 years ago

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