When I ask which version of gcc I have, I get the following:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

When I try to get information about gcc: ls -la /usr/bin |grep gcc

I get:

-rwxr-xr-x     1 root   wheel     18288 May 29  2018 gcc
-rwxr-xr-x     1 root   wheel      2043 Sep 26  2016 gccmakedep
lrwxr-xr-x     1 root   wheel         5 Mar 28  2018 llvm-gcc -> clang

I am using MacOS 10.13.5, and the reason that I want to use gcc instead of clang is because I have code I want to run in MATLAB that is in C, but I can't compile the code with clang, because fopenmp is unsupported.

When I try to compile just the matlab part of the program so that I can run it with a matlab interface:

make matlab

I get the following error:

gcc -std=c99 -pedantic -Wall -O3 -fopenmp -DSSHT_VERSION=\"1.2b1\"...

clang: error: unsupported option '-fopenmp'

I used the link: Installed gcc with Homebrew, now how to use that gcc instead of clang?

export PATH=/usr/bin
export CXX=/usr/local/Cellar/gcc/8.2.0/bin/g++-8
export CC=/usr/local/Cellar/gcc/8.2.0/bin/gcc-8

to my code.

  • Welcome to Ask Different. - This gets asked quite a bit so forgive me for presuming you are using the built in gcc which calls clang to act like gcc instead of being gcc - If so, does this answer your entire question? apple.stackexchange.com/questions/245891/…
    – bmike
    Jan 14, 2019 at 19:49
  • The version of gcc I have is from homebrew. It is 8.2.0. I tried the solution in that link prior to posting this, but it did not work for me. Jan 14, 2019 at 21:49
  • Perfect - I would make a small edit - say you used the link (in the body) to get gcc (and show your path to gcc / version) if you want to reinforce that. Not everyone will see the comments. Glad I didn't close as dupe on an assumption / presumption. Nice problem - I hope the collective "we" can help
    – bmike
    Jan 14, 2019 at 21:51
  • Ok. Thank you. I'm obviously very new to this. I will edit. I have also found a similar solution, so maybe this is a dupe. Jan 14, 2019 at 21:52
  • I added: export PATH=/usr/bin export CXX=/usr/local/Cellar/gcc/8.2.0/bin/g++-8 export CC=/usr/local/Cellar/gcc/8.2.0/bin/gcc-8 Jan 14, 2019 at 21:53

2 Answers 2


Apple and xcode do not provide gcc. Any file called gcc us a link to clang

You need to install gcc from a third party and also check the version has mp enabled.

The easiest way is to install gcc using a package manager like macports, homebrew or fink.

  • Mark - would there be a way to pass the mp enable to brew so that it gets compiled in? I'm super rusty on gcc and don't want to assign homework - but if you happened to just know...
    – bmike
    Jan 14, 2019 at 21:52
  • I had to directly specify the path of my gcc in the code, but it worked: Jan 14, 2019 at 21:57
  • @bmike - I am not a Homebrew expert but dosn't brew just install programs. So it just adds a program e.g gcc to the $PATH
    – mmmmmm
    Jan 15, 2019 at 0:41
  • It can compile from source and only if you choose the default options does it download a pre build package. In the past, when I needed ssl support in mongodb I had to pass -withssl to the brew to have it add those compile flags. askmhs.blogspot.com/2016/11/… In this case, my question is a side issue since I misunderstood the ask. It's simply how to change the path and send the alternate path to build scripts if I understand it better now.
    – bmike
    Jan 15, 2019 at 3:24
  • Any ideas on this one: Separate complex matrix function mxGetPi was called. Either update the source code for interleaved complex, or rerun MEX with the -R2017b command line option to use the R2017b API with compatibility support. For more information, see <a href="matlab: helpview([docroot '/matlab/helptargets.map'],'support_for_IC_API')">Interleaved Complex</a> make: *** [/Users/.../Dropbox/Code/ssht-public/src/matlab/ssht_forward_mex.mexmaci64] Error 255 I'm running MATLAB2018a. I don't even understand what the reference to R2017b is referring to. Jan 16, 2019 at 14:27

Having gcc installed with homebrew, directly point to the where it is installed in the beginning of the code to compile (makefile):

export CXX=/usr/local/Cellar/gcc/8.2.0/bin/g++-8
export CC=/usr/local/Cellar/gcc/8.2.0/bin/gcc-8
  • That is not a good setting for PATH /bin at last would be needed e.g. for cp and mv
    – mmmmmm
    Jan 17, 2019 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .