I've recently been having problems with compiling packages for R. I'm not sure of the causes but one possibility is that there are a couple of different versions of gcc on my MacBook Pro. When I type which gcc
in a terminal window it returns /usr/bin/gcc
. But when I type gcc –version I get back
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I may also have some issues with the path. It is currently set to
/usr/local/sbin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/usr/local/bin:/usr/bin:/bin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin:/usr/local/git/bin
I added the Applications… path to PATH hoping it would help but it didn't. /usr/bin contains both a g++ and gcc file install May 18, so very recently. I've tried renaming those as a test of whether that would solve the problem but I'm unable to do that even as sudo.
Suggestions greatly appreciated!
Best Answer
For macOS Clang is a more preferred option (Apple stopped shipping gcc with Xcode and replaced it with Clang and the last version of GCC they supported was 4.2.1, it'll overall be more intuitive.). I'd remove GCC and do the following:
Installation of Clang
brew update
and thenbrew upgrade
in terminalbrew install llvm
to install LLVM and ClangTo put Clang within your PATH variables:
I'm not too sure how different the two are when it comes to compiling (although they are probably very similar.) you can proceed with this link to catch up on the commands you'll need to use instead.