brew 安装 clang-omp 不工作

brew install clang-omp not working

我需要在 Mac 上使用 OpenMP 编译 C++ 代码。不幸的是,安装在 Mac (703.0.31) 上的默认 clang 版本不支持 OpenMP。 因此,我正在尝试使用 brew 安装 clang-omp 包(例如,遵循 this 指南)。问题是 brew 既找不到 libiomp,也找不到 clang-omp 包:

$ brew install clang-omp
Error: No available formula with the name "clang-omp"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.

我想知道 clang-omp 是否仍然由 brew 提供。还是我做错了什么?有什么想法吗?

编辑:如果我执行 brew search,我会得到以下信息:

$ brew search clang
clang-format           emacs-clang-complete-async
Caskroom/cask/openclonk-c54d917-darwin-amd64-clang

因此,没有 clang-omp 的证据。我有可能必须更改存储库或类似的东西吗?

安装已删除的公式

brew install homebrew/boneyard/clamp-omp

brew tap homebrew/boneyard
brew install clang-omp

参考:https://superuser.com/questions/1110414/install-a-deleted-homebrew-formulae/1110934#1110934

然后需要设置环境:

export C_INCLUDE_PATH=/usr/local/Cellar/libiomp/20150401/include/libiomp:$C_INCLUDE_PATH

export CPLUS_INCLUDE_PATH=/usr/local/Cellar/libiomp/!date!/include/libiomp:$CPLUS_INCLUDE_PATH

export LIBRARY_PATH=/usr/local/Cellar/libiomp/!date!/lib:$LIBRARY_PATH

您可以使用 brew 安装 llvm,因为它现在包含 openmp。

brew install llvm

如果需要,您可以创建符号链接

ln -s /usr/local/opt/llvm/bin/clang /usr/local/bin/clang-omp

我的 makefile 看起来像这样

CPP = /usr/local/opt/llvm/bin/clang
CPPFLAGS = -I/usr/local/opt/llvm/include -fopenmp
LDFLAGS = -L/usr/local/opt/llvm/lib

example: example.c
    $(CPP) $(CPPFLAGS) $^ -o $@ $(LDFLAGS)

clang-ompboneyarded。请参阅此提交:https://github.com/Homebrew/homebrew-core/commit/c57e30773:

clang-omp:迁移到墓地

功能现在作为 LLVM 的一部分在 Homebrew 中可用。 所以只需安装 llvm

OpenMP 正式包含在brew 中(方法之前,要么安装llvm,要么安装过时的clang-omp)。

brew install libomp