1

I'm having trouble finding how to change the default c++ compiler from clang to the homebrew version of gcc I have installed. The end goal here is to be able to run a command line gradle build using gcc.

I've checked to make sure that the first directory in the PATH variable is /usr/local/bin as suggested in some places, but it still defaults to clang/LLVM

mpviv
  • 11
  • 1
  • 4
  • Old post, but probably still relevant(-ish): https://stackoverflow.com/questions/28970935/osx-replace-gcc-version-4-2-1-with-4-9-installed-via-homebrew – Eljay Nov 21 '19 at 01:37
  • Did you reload your ~/.bashrc after changing the PATH variable? what is the output of `which gcc`, `gcc -v`? – A. K. Nov 23 '19 at 08:46

1 Answers1

0

I have fixed that issue by setting up symbolic links to the GCC:

ln -s /usr/local/bin/g++-${VERSION} /usr/local/bin/g++
ln -s /usr/local/bin/gcc-${VERSION} /usr/local/bin/gcc

GCC installation shouldn't provide that links (there can be a lot of different versions of GCC, so which should be linked?), but /usr/bin/gcc exists. So if you ask the system for GCC, it will run this one.

Everything should work after adding these links and checking PATH if /usr/local/bin is before /usr/bin/gcc.

It works for me even on GitHub Actions MacOS job.

Norbert
  • 11
  • 3