Installazione di gcc47 come default usando Homebrew

1

Sto cercando di installare gcc47 come compilatore predefinito usando homebrew. Posso installare correttamente gcc47, ma aggiunge un suffisso -4.7 su tutti i suoi binari. Se provo a collegarlo in / usr / local / bin, le cose si complicano. Considera questo:

$ 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
    
posta Mike Goodspeed 28.03.2013 - 17:37
fonte

1 risposta

1

Se vuoi fare qualcosa di un po 'più semplice da ripristinare in seguito, puoi sempre fare un alias nel tuo file bashrc.

alias gcc gcc-4.7

Questo convertirà automaticamente tutto per te dalla riga di comando. Il rovescio della medaglia è che funziona solo quando il tuo bashrc è usato e solo per il tuo utente (che potrebbe anche essere un positivo).

    
risposta data 21.11.2013 - 14:24
fonte

Leggi altre domande sui tag