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.
Best Answer
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.