Installing gcc47 as default using Homebrew I'm trying to install gcc47 as my default compiler using homebrew.  I can successfully install gcc47, but it adds a -4.7 suffix on all of its binaries.  If I try to symlink it in /usr/local/bin things get tricky.  Consider this:

$ which gcc
/usr/bin/gcc
$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ ln -s /usr/local/bin/gcc-4.7 /usr/local/bin/gcc
$ which gcc
/usr/local/bin/gcc
$ gcc --version
gcc-4.7: err    or trying to exec '/usr/local/bin/../Cellar/gcc47/4.7.2/bin/i686-apple-darwin11-llvm-gcc-4.2': execvp: No such file or directory
$ ls -l /usr/local/bin/*gcc* /usr/local/bin/*g++*
lrwxr-xr-x  1 mike  staff  33 Mar 27 15:48 /usr/local/bin/g++-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/g++-4.7
lrwxr-xr-x  1 mike  staff  22 Mar 28 11:32 /usr/local/bin/gcc -&gt; /usr/local/bin/gcc-4.7
lrwxr-xr-x  1 mike  staff  33 Mar 27 15:48 /usr/local/bin/gcc-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/gcc-4.7
lrwxr-xr-x  1 mike  staff  36 Mar 27 15:48 /usr/local/bin/gcc-ar-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/gcc-ar-4.7
lrwxr-xr-x  1 mike  staff  36 Mar 27 15:48 /usr/local/bin/gcc-nm-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/gcc-nm-4.7
lrwxr-xr-x  1 mike  staff  40 Mar 27 15:48 /usr/local/bin/gcc-ranlib-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/gcc-ranlib-4.7
lrwxr-xr-x  1 mike  staff  59 Mar 27 15:48 /usr/local/bin/x86_64-apple-darwin12.3.0-g++-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-g++-4.7
lrwxr-xr-x  1 mike  staff  59 Mar 27 15:48 /usr/local/bin/x86_64-apple-darwin12.3.0-gcc-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-gcc-4.7
lrwxr-xr-x  1 mike  staff  61 Mar 27 15:48 /usr/local/bin/x86_64-apple-darwin12.3.0-gcc-4.7.2 -&gt; ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-gcc-4.7.2
lrwxr-xr-x  1 mike  staff  62 Mar 27 15:48 /usr/local/bin/x86_64-apple-darwin12.3.0-gcc-ar-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-gcc-ar-4.7
lrwxr-xr-x  1 mike  staff  62 Mar 27 15:48 /usr/local/bin/x86_64-apple-darwin12.3.0-gcc-nm-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-gcc-nm-4.7
lrwxr-xr-x  1 mike  staff  66 Mar 27 15:48 /usr/local/bin/x86_64-apple-darwin12.3.0-gcc-ranlib-4.7 -&gt; ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-gcc-ranlib-4.7
If you want to do something a little easier to revert later, you can always make an alias in your bashrc file. 

alias gcc gcc-4.7


This will automatically convert everything for you from the command line. The downside is that it only works when your bashrc is used and only for your user (which could also be a positive).