28

I need to compile a C++ code with OpenMP on my Mac. Unfortunately the default version of clang installed on the Mac (703.0.31) does not support OpenMP. Therefore, I am trying to install the clang-omp package with brew (e.g., following this guide). The issue is that brew cannot find neither the libiomp, nor the clang-omp package:

$ 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.

I am wondering whether clang-omp is still provided by brew. Or am I doing something wrong? Any ideas?

Edit: If I do brew search I get the following:

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

Thus, no evidence of clang-omp. Is it possible I have to change repository or something like this?

mtazzari
  • 451
  • 1
  • 5
  • 14
  • Have you updated the `brew` recipes by calling `brew update` first? – Hristo Iliev Aug 16 '16 at 13:08
  • @HristoIliev Yes, I did it. Just to be sure, I have re-done it right now (I have updated Homebrew from 87173cb to 984ed83) but still clang-omp is not found (I get the same error above). – mtazzari Aug 16 '16 at 14:39
  • 5
    LLVM 3.8 and later should support OpenMP "out of the box". Therefore there should no longer be any need to have a specific, different, clang-omp... – Jim Cownie Aug 16 '16 at 14:57
  • You could use `gcc v6` to compile C++ with OpenMP. You can install with `brew install gcc --without-multilib` – Mark Setchell Sep 09 '16 at 13:46
  • @JimCownie How would you compile C++11 compliant `main.cpp` which uses OpenMP with LLVM please - what would be the full command-line? – Mark Setchell Sep 09 '16 at 13:55
  • you can reference to link http://macappstore.org/clang-omp/ – 冯剑龙 Apr 12 '19 at 05:38

4 Answers4

39

You can install llvm using brew since it now includes openmp.

brew install llvm

You can make a symlink if you want

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

My makefile looks like this

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)
slek120
  • 1,115
  • 11
  • 13
  • 1
    It says `omp.h` doesn't exists. Is it possible if you could provide an example, will be very helpful as i'm struggling to get it work with openmp. – Piyush Chauhan Dec 06 '16 at 11:07
  • @PiyushChauhan If I run `make` using the makefile in the answer, it would run `/usr/local/opt/llvm/bin/clang -I/usr/local/opt/llvm/include -fopenmp example.c -o example -L/usr/local/opt/llvm/include` – slek120 Dec 07 '16 at 17:49
  • What is the optional symlink step for? `ln -s /usr/local/opt/llvm/bin/clang /usr/local/bin/clang-omp` – Carmen Sandoval May 09 '18 at 23:56
  • The symlink is to put it in your path. I added the `-omp` to separate it from default `clang` and because it used to be called `clang-omp` in brew. – slek120 May 11 '18 at 01:37
11

Install a deleted formula

brew install homebrew/boneyard/clamp-omp

OR

brew tap homebrew/boneyard
brew install clang-omp

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

Then you need to set the environment:

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
Community
  • 1
  • 1
Microos
  • 1,728
  • 3
  • 17
  • 34
8

clang-omp has been boneyarded. See this commit: https://github.com/Homebrew/homebrew-core/commit/c57e30773:

clang-omp: migrate to boneyard

Functionality is now available as part of LLVM in Homebrew. So just install llvm

HenryZhao
  • 831
  • 8
  • 6
  • 3
    I've just install `llvm` using `brew install llvm`. Still, the program I want to use ([LDSTORE](http://www.christianbenner.com/#)) is not working, stating `dyld: Library not loaded: /usr/local/opt/libiomp/lib/libiomp5.dylib`. How do I make sure that it is properly loaded? Where do I do this? – Sander W. van der Laan Oct 30 '17 at 11:11
2

OpenMP was officially included in the brew (before the method, either install llvm, or outdated clang-omp).

brew install libomp
冯剑龙
  • 569
  • 8
  • 22