librelist archives

« back to archive

How to switch the gcc with home-brew?

How to switch the gcc with home-brew?

From:
心如烛光
Date:
2015-09-28 @ 16:15
Hi,
I have installed the newest gcc(5.2.0)for my osx(10.10.5)with homebrew.But
when it runs:"gcc -v",it still returns"gcc version 4.9.0".How could I 
switch the gcc from v4.9 to v5.2?Thank you!


Here is what the brew returns:

$ brew list gcc

/usr/local/Cellar/gcc/5.2.0/bin/c++-5

/usr/local/Cellar/gcc/5.2.0/bin/cpp-5

/usr/local/Cellar/gcc/5.2.0/bin/g++-5

/usr/local/Cellar/gcc/5.2.0/bin/gcc-5

/usr/local/Cellar/gcc/5.2.0/bin/gcc-ar-5

/usr/local/Cellar/gcc/5.2.0/bin/gcc-nm-5

/usr/local/Cellar/gcc/5.2.0/bin/gcc-ranlib-5

/usr/local/Cellar/gcc/5.2.0/bin/gcov-5

/usr/local/Cellar/gcc/5.2.0/bin/gcov-tool-5

/usr/local/Cellar/gcc/5.2.0/bin/gfortran

/usr/local/Cellar/gcc/5.2.0/bin/gfortran-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-c++-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-g++-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-gcc-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-gcc-5.2.0

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-gcc-ar-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-gcc-nm-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-gcc-ranlib-5

/usr/local/Cellar/gcc/5.2.0/bin/x86_64-apple-darwin14.4.0-gfortran-5

/usr/local/Cellar/gcc/5.2.0/include/c++/ (721 files)

/usr/local/Cellar/gcc/5.2.0/lib/gcc/ (612 files)

/usr/local/Cellar/gcc/5.2.0/libexec/gcc/ (13 files)

/usr/local/Cellar/gcc/5.2.0/share/gcc-5.2.0/ (4 files)

/usr/local/Cellar/gcc/5.2.0/share/man/ (8 files)




And below is what the command"gcc -v" returns:

$ gcc -v

gcc: warning: couldn’t understand kern.osversion ‘14.5.0

Using built-in specs.

COLLECT_GCC=gcc


COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin12.4.0/4.9.0/lto-wrapper

Target: x86_64-apple-darwin12.4.0

Configured with: ../gcc-4.9-20130811/configure --enable-languages=fortran,c++

Thread model: posix



gcc version 4.9.0 20130811 (experimental) (GCC)