ChemPy:clang:错误:不支持的选项“-fopenmp”
Posted
技术标签:
【中文标题】ChemPy:clang:错误:不支持的选项“-fopenmp”【英文标题】:ChemPy: clang: error: unsupported option '-fopenmp' 【发布时间】:2020-10-14 07:54:12 【问题描述】:我正在尝试解决以下问题。当我尝试在this ntb 中运行以下行时,我得到:
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
我认为fopenmp
和gcc
可能有问题,如那些地方(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)所述,但建议的解决方案(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) 只是不适合我。我也尝试使用 conda 安装 GCC,但我得到:
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
使用homebrew
我安装了gcc
...知道发生了什么以及如何解决它吗?我正在运行 MacOS 10.15.7。谢谢
【问题讨论】:
homebrew 将安装类似/usr/local/bin/g++-10
的东西
【参考方案1】:
homebrew 将安装类似的东西:
/usr/local/bin/g++-10
您可以通过以下方式准确检查安装的内容和位置:
brew ls gcc
样本输出
/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)
然后你可以找到你应该像这样实际使用的符号链接二进制文件:
cd /usr/local/bin
ls -l | grep gcc
样本输出
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
因此,一旦确定了要使用的编译器,就需要告诉构建工具如何使用它。我不熟悉您提到的软件包,但您帖子的第四行暗示它正在使用 /usr/bin/g++
,如果您想使用 homebrew /usr/local/bin/g++-10
,这是不正确的。
指定不同编译器的常用方法有:
对于 CMake:CXX=/usr/local/bin/g++-10 cmake ..
制作:make CXX=/usr/local/bin/g++-10
对于 autoconf:./configure CXX=/usr/local/bin/g++-10
【讨论】:
嗨,马克,感谢您的回答。是的,我所拥有的一切和你的相似。那么接下来该怎么做呢?我应该如何让 python/chempy 知道去哪里看?或者是什么问题?为什么看不到对方? 我在答案末尾添加了更新 - 请再看一下。【参考方案2】:我花了很长时间,最终有两个主要问题我认为可能对其他人有用。
ChemPy 仅在 Linux 上受支持,所以即使我让我的编译器工作,我也没有让它在 Mac 或 Windows 上运行。有关更多信息,请参阅 Github 上的 issue。
编译器一团糟。最后起作用的是使用 Anaconda 环境中的 clang v10 而不是 v12:
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
只是为了让它完整,这里有什么和工作:
(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
【讨论】:
以上是关于ChemPy:clang:错误:不支持的选项“-fopenmp”的主要内容,如果未能解决你的问题,请参考以下文章
clang++ 的选项 -fno-strict-enums 有啥作用?