Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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 -> ../Cellar/gcc47/4.7.2/bin/g++-4.7
lrwxr-xr-x  1 mike  staff  22 Mar 28 11:32 /usr/local/bin/gcc -> /usr/local/bin/gcc-4.7
lrwxr-xr-x  1 mike  staff  33 Mar 27 15:48 /usr/local/bin/gcc-4.7 -> ../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 -> ../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 -> ../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 -> ../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 -> ../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 -> ../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 -> ../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 -> ../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 -> ../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 -> ../Cellar/gcc47/4.7.2/bin/x86_64-apple-darwin12.3.0-gcc-ranlib-4.7
share|improve this question
    
FWIW, this works fine for me. I don't see anything wrong with your approach in principle. –  Peter Eisentraut May 3 '13 at 12:42

1 Answer 1

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).

share|improve this answer
    
Isn't it ~/.bash_profile? –  miguel.martin Mar 10 at 4:06
    
Yeah. I forgot I had source .bashrc in my .bash_profile –  Wesley Bland Mar 10 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.