I've installed gcc-5 via brew install gcc5, and I've tried linking gcc (which is clang by default) to gcc-5, but whenever I try running gcc, it's using clang. I've also checked that /usr/local/bin is first in my PATH variable. Here's how it all looks in my terminal:

$ which gcc-5
$ which gcc
$ echo $PATH
$ gcc
clang: error: no input files
$ gcc-5
gcc-5: fatal error: no input files
compilation terminated.
$ ln -sf gcc-5 gcc
$ gcc
clang: error: no input files

Also, in ~/.bash_profile, I've put export PATH="/usr/local/bin:$PATH" in the last line of the file, and it appears 1st in $PATH, I've played around a bit and discovered that it's somehow read in reverse, as if every export appends to the front, is that normal behaviour?

EDIT: I would prefer to avoid using alias for things like these.

  • What does which gcc show (or better type -p gcc) - also why do this any build system will allow an easy chnage of C++ compiler
    – mmmmmm
    Oct 23 '15 at 11:01
ln -sf gcc-5 gcc

You might be thinking of an alias, but that symbolic link doesn't really do anything unless you're in /usr/local/bin. You need

ln -sf /usr/local/bin/gcc-5 /usr/local/bin/gcc

You must log in to answer this question.

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