LightGBM icon indicating copy to clipboard operation
LightGBM copied to clipboard

[RESOLVED] unsupported option '-fopenmp' on Mac OS X

Open Yorko opened this issue 10 years ago • 30 comments

Is Mac OS X supported?

I'm on 10.12 Sierra and get the "unsupported option '-fopenmp'" error after "make -j"

Yorko avatar Oct 16 '16 15:10 Yorko

Actually, It is not tested on OSX now. Will fix soon

guolinke avatar Oct 16 '16 16:10 guolinke

Maybe it'll work with Clang updated, I'll try.

Yorko avatar Oct 16 '16 16:10 Yorko

hi, @Yorko , we currently doesn't have clear plan to support OSX (but it should have). However, this issue is caused by that OpenMP is needed by lightGBM for building, please refer to https://clang-omp.github.io/ for the instuctions

chivee avatar Oct 17 '16 02:10 chivee

I'll close this issue first, please feel free to reopen if the problem still there after installing OpenMP properly.

chivee avatar Oct 17 '16 05:10 chivee

On mac os sierra, installing OpenMPI with with homebrew and following instructions still resulted in same error. Installing using C++11 mode and with C++ MPI bindings (these were flags for the homebrew recipe) did not fix the error.

sooheon avatar Oct 17 '16 07:10 sooheon

hi @sooheon , i'm not quite sure that you are confusing openMP with openMPI(or just an typo) which doesn't needed by lightGBM by default. since I don't have an sierra , I'm not quite sure that apple clang has openMP supported on sierra. the 10.11 OSX has the clang version accord to ~3.7, and openMP was default supported since 3.8.

if you using gcc as your default compiler on sierra. the build should succeed.

chivee avatar Oct 17 '16 08:10 chivee

Compiling LightGBM with gcc-6 on OSX works:

brew install cmake gcc
cmake -DCMAKE_CXX_COMPILER=g++-6 CMakeLists.txt
make

bartleusink avatar Oct 17 '16 08:10 bartleusink

Thank you I was indeed confusing OpenMPI and OpenMP

sooheon avatar Oct 17 '16 08:10 sooheon

@bartleusink , thanks for your sharing

chivee avatar Oct 17 '16 09:10 chivee

@bartleusink Thank you! For me it finally worked.

If anybody's interested: I had to additionally link brew to gcc so that g++-6 is in path.

sudo chown -R $USER /usr/local/ brew link --overwrite gcc

Yorko avatar Oct 17 '16 10:10 Yorko

@Yorko Hi. I tried doing the brew link --overwrite gcc and got this error Error: No such keg: /usr/local/Cellar/gcc

do you know why?

BeatriceGR avatar Jun 28 '17 22:06 BeatriceGR

Same problem as BeatricGR! Any ideas?

ktorimaru avatar Jul 06 '17 23:07 ktorimaru

@BeatriceGR @ktorimaru Use following command to install gcc in osx:

brew install gcc --without-multilib

guolinke avatar Jul 07 '17 04:07 guolinke

By the way, non-Apple LLVM on macOS works just fine, as well. Just use brew install llvm (that'll get 5.0, with OpenMP), and set up the environment for the compiler in /usr/local/opt/llvm. In Sierra, with Apple Clang based on 3.9, and High Sierra, with Apple Clang based on 4.0, the OpenMP library is disabled on the built-in compiler. (even though the -fopenmp-targets option slipped through!)

henryiii avatar Sep 25 '17 21:09 henryiii

Hi !

I'm trying to install gcc --without-multilib too, but the option seems to have disappeared from brew. The command given by @guolinke does'n work any more.

BTW, im on High Sierra, 10.13.1.

Any luck that you guys have a solution ?

Thanks, Clovel

Clovel avatar Nov 08 '17 19:11 Clovel

@Clovel after installing gcc --without-multilib try to run gcc specific version compiler: gcc-7 -fopenmp hello_par.c -o hello_par

ghost avatar Jan 21 '18 22:01 ghost

@piotrek1543 THANK YOU! Only solution after fighting for hours.

stajahlee avatar Feb 04 '18 18:02 stajahlee

@Clovel I can't install with option of "--without-multilib" either. But it's funny that, after I changed " gcc -fopenmp ...... " to " gcc-7 -fopenmp ......", it doesn't return clang error and works! @piotrek1543 Thank you!

Jemma1um avatar Feb 14 '18 18:02 Jemma1um

Please have a look at : https://stackoverflow.com/a/50313990/3465857

tanmayGIT avatar May 13 '18 08:05 tanmayGIT

Can anyone solve my issue: clang: error: unsupported option '-fopenmp'

I am totally new to terminal and want to use openmp but I am getting above error; I copied and run all the above commands (as mentioned above) but the problem persists. Currently, I am using high Sierra 10.13.6.

itzzmeanmol avatar Jul 22 '18 14:07 itzzmeanmol