EDIT: As of 13 Aug 2017 the --without-multilib
option is no longer present in Homebrew and should not be used. The standard installation
brew install gcc
will provide a gcc
installation that can be used to compile OpenMP programs. As below it will be installed into /usr/local/bin
as gcc-<version>
. The current gcc version available from Homebrew (as of writing) will install as gcc-8
. You can compile programs with OpenMP support using it via
gcc-8 -fopenmp hello.c
Alternatively you could put an alias in your .bashrc
file as
alias gcc='gcc-8'
and then compile using
gcc -fopenmp hello.c
Note: I'm leaving the original post here in case it is useful to somebody.
The standard gcc available on OS X through XCode and Clang doesn't support OpenMP. To install the Homebrew version of gcc with OpenMP support you need to install it with
brew install gcc --without-multilib
or as pointed out by @Mark Setchell
brew reinstall gcc --without-multilib
This will install it to the /usr/local/bin
directory. Homebrew will install it as gcc-<version>
so as not to clobber the gcc bundled with XCode.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…