简体   繁体   中英

ChemPy: clang: error: unsupported option '-fopenmp'

I am trying to fix the following problem. When I was trying to run the following line in this ntb , I am getting:

native = get_native(rsys, odesys, 'cvode')

INFO:pyodesys.native._base:Cythonizing /Users/user/Library/Caches/python3.8-pyodesys-0.13.1/_cvode_wrapper.pyx to ./_cvode_wrapper.cpp
INFO:pyodesys.native._base:In "/var/folders/bx/tb4883l53hdd3zp2y0nyy_4m0000gp/T/tmpt2vuw8pg", executing:
"/usr/bin/g++ -fwrapv -pthread -c -std=c++11 -Wall -Wextra -fPIC -O2 -ffast-math -funroll-loops -fopenmp -fno-strict-aliasing -o ./_cvode_wrapper.o -DPYCVODES_NO_KLU=0 -DPYCVODES_NO_LAPACK=0 -DANYODE_NO_LAPACK=0 -I/Users/user/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/Users/jan/anaconda3/lib/python3.8/site-packages/pyodesys/native/sources -I/Users/jan/anaconda3/lib/python3.8/site-packages/pycvodes/include -I/Users/jan/anaconda3/include/python3.8 ./_cvode_wrapper.cpp"
CompilationError: Error executing '/usr/bin/g++ -fwrapv -pthread -c -std=c++11 -Wall -Wextra -fPIC -O2 -ffast-math -funroll-loops -fopenmp -fno-strict-aliasing -o ./_cvode_wrapper.o -DPYCVODES_NO_KLU=0 -DPYCVODES_NO_LAPACK=0 -DANYODE_NO_LAPACK=0 -I/Users/jan/anaconda3/lib/python3.8/site-packages/numpy/core/include -I/Users/jan/anaconda3/lib/python3.8/site-packages/pyodesys/native/sources -I/Users/jan/anaconda3/lib/python3.8/site-packages/pycvodes/include -I/Users/jan/anaconda3/include/python3.8 ./_cvode_wrapper.cpp' in /var/folders/bx/tb4883l53hdd3zp2y0nyy_4m0000gp/T/tmpt2vuw8pg. Command exited with status 1 after givning the following output: clang: error: unsupported option '-fopenmp

I thought it might be a problem with the fopenmp and gcc as stated at those places ( How to deal with "clang: error: unsupported option '-fopenmp'" on travis? , https://github.com/microsoft/LightGBM/issues/3 , https://github.com/velocyto-team/velocyto.R/issues/2 ) but the proposed solutions ( https://github.com/velocyto-team/velocyto.R/issues/2#issuecomment-341165967 , https://github.com/microsoft/LightGBM/issues/3#issuecomment-254149689 , https://github.com/kharchenkolab/conos/wiki/Installing-Conos-for-Mac-OS ) just do not work for me. I have also tried to install GCC using conda but I get:

conda install gcc
PackagesNotFoundError: The following packages are not available from current channels:

  - gcc

Current channels:

  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch

Using homebrew I have gcc installed... Any idea what is going on and how to fix it? I am running MacOS 10.15.7. Thanks

homebrew will have installed something like:

/usr/local/bin/g++-10

You can check exactly what it installed and where with:

brew ls gcc

Sample Output

/usr/local/Cellar/gcc/10.2.0/bin/c++-10
/usr/local/Cellar/gcc/10.2.0/bin/cpp-10
/usr/local/Cellar/gcc/10.2.0/bin/g++-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-ar-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-nm-10
/usr/local/Cellar/gcc/10.2.0/bin/gcc-ranlib-10
/usr/local/Cellar/gcc/10.2.0/bin/gcov-10
/usr/local/Cellar/gcc/10.2.0/bin/gcov-dump-10
/usr/local/Cellar/gcc/10.2.0/bin/gcov-tool-10
/usr/local/Cellar/gcc/10.2.0/bin/gfortran
/usr/local/Cellar/gcc/10.2.0/bin/gfortran-10
/usr/local/Cellar/gcc/10.2.0/bin/lto-dump-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-c++-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-g++-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10.2.0
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ar-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-nm-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ranlib-10
/usr/local/Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gfortran-10
/usr/local/Cellar/gcc/10.2.0/include/c++/ (770 files)
/usr/local/Cellar/gcc/10.2.0/lib/gcc/ (638 files)
/usr/local/Cellar/gcc/10.2.0/libexec/gcc/ (13 files)
/usr/local/Cellar/gcc/10.2.0/share/gcc-10.2.0/ (4 files)
/usr/local/Cellar/gcc/10.2.0/share/man/ (11 files)

And then you can find the symlinked binaries you should actually use like this:

cd /usr/local/bin
ls -l | grep gcc

Sample Output

lrwxr-xr-x   1 mark  admin        31 21 Aug 16:41 c++-10 -> ../Cellar/gcc/10.2.0/bin/c++-10
lrwxr-xr-x   1 mark  admin        31 21 Aug 16:41 cpp-10 -> ../Cellar/gcc/10.2.0/bin/cpp-10
lrwxr-xr-x   1 mark  admin        31 21 Aug 16:41 g++-10 -> ../Cellar/gcc/10.2.0/bin/g++-10
lrwxr-xr-x   1 mark  admin        31 21 Aug 16:41 gcc-10 -> ../Cellar/gcc/10.2.0/bin/gcc-10
lrwxr-xr-x   1 mark  admin        34 21 Aug 16:41 gcc-ar-10 -> ../Cellar/gcc/10.2.0/bin/gcc-ar-10
lrwxr-xr-x   1 mark  admin        34 21 Aug 16:41 gcc-nm-10 -> ../Cellar/gcc/10.2.0/bin/gcc-nm-10
lrwxr-xr-x   1 mark  admin        38 21 Aug 16:41 gcc-ranlib-10 -> ../Cellar/gcc/10.2.0/bin/gcc-ranlib-10
lrwxr-xr-x   1 mark  admin        32 21 Aug 16:41 gcov-10 -> ../Cellar/gcc/10.2.0/bin/gcov-10
lrwxr-xr-x   1 mark  admin        37 21 Aug 16:41 gcov-dump-10 -> ../Cellar/gcc/10.2.0/bin/gcov-dump-10
lrwxr-xr-x   1 mark  admin        37 21 Aug 16:41 gcov-tool-10 -> ../Cellar/gcc/10.2.0/bin/gcov-tool-10
lrwxr-xr-x   1 mark  admin        33 21 Aug 16:41 gfortran -> ../Cellar/gcc/10.2.0/bin/gfortran
lrwxr-xr-x   1 mark  admin        36 21 Aug 16:41 gfortran-10 -> ../Cellar/gcc/10.2.0/bin/gfortran-10
lrwxr-xr-x   1 mark  admin        36 21 Aug 16:41 lto-dump-10 -> ../Cellar/gcc/10.2.0/bin/lto-dump-10
lrwxr-xr-x   1 mark  admin        53 21 Aug 16:41 x86_64-apple-darwin19-c++-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-c++-10
lrwxr-xr-x   1 mark  admin        53 21 Aug 16:41 x86_64-apple-darwin19-g++-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-g++-10
lrwxr-xr-x   1 mark  admin        53 21 Aug 16:41 x86_64-apple-darwin19-gcc-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10
lrwxr-xr-x   1 mark  admin        57 21 Aug 16:41 x86_64-apple-darwin19-gcc-10.2.0 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-10.2.0
lrwxr-xr-x   1 mark  admin        56 21 Aug 16:41 x86_64-apple-darwin19-gcc-ar-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ar-10
lrwxr-xr-x   1 mark  admin        56 21 Aug 16:41 x86_64-apple-darwin19-gcc-nm-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-nm-10
lrwxr-xr-x   1 mark  admin        60 21 Aug 16:41 x86_64-apple-darwin19-gcc-ranlib-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gcc-ranlib-10
lrwxr-xr-x   1 mark  admin        58 21 Aug 16:41 x86_64-apple-darwin19-gfortran-10 -> ../Cellar/gcc/10.2.0/bin/x86_64-apple-darwin19-gfortran-10

So, once you have determined which compiler you want to use, you need to tell your build tool how to use it. I am unfamiliar with the package you mention, but the fourth line of your post implies it is using /usr/bin/g++ which is not correct if you want to use the homebrew /usr/local/bin/g++-10 .

The common ways of specifying a different compiler are:

  • for CMake : CXX=/usr/local/bin/g++-10 cmake ..
  • for make : make CXX=/usr/local/bin/g++-10
  • for autoconf : ./configure CXX=/usr/local/bin/g++-10

It took me a very long time, eventually there were two main issues which I think might be useful for others.

  1. ChemPy is only supported on Linux so even when I made my compilers working, I did not make it run on Mac nor on Windows. For more see this issue on Github.

  2. The compilers were a mess. At the end what worked was to use clang v10 from Anaconda environment and not v12:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++

Just to make it complete, here it what is there and working:

(base) bash-3.2$ clang --version
clang version 10.0.0
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Users/user/anaconda3/bin
(base) bash-3.2$ which clang
/Users/user/anaconda3/bin/clang

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM