Is it possible to completely remove GCC from my mac? If so, how do I do that?


I recently completely messed up GCC after attempting to get it to work with openMP. Right now GCC can't even compile/run a simple "helloworld" program in C. When I type in "gcc helloworld.c -o Result", it gives me an "ld: library not found for -lgcc" error.

Every single time I try to install gcc/reinstall gcc by doing something like gcc with --without-multilib, it gives me something like this:

==> Reinstalling gcc with --without-multilib
==> Downloading http://ftpmirror.gnu.org/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2
==> Downloading from http://open-source-box.org/gcc/gcc-5.3.0/gcc-5.3.0.tar.bz2
######################################################################## 100.0%

^[[D==> Patching
patching file gcc/jit/Make-lang.in
patching file gcc/jit/jit-playback.c
Hunk #1 succeeded at 2470 with fuzz 2 (offset 54 lines).
==> ../configure --build=x86_64-apple-darwin15.2.0 --prefix=/usr/local/Cellar/gc
^R

==> make bootstrap
Last 15 lines from /Users/bettyjing/Library/Logs/Homebrew/gcc/02.make:
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... awk
checking for x86_64-apple-darwin15.2.0-ar... ar
checking for x86_64-apple-darwin15.2.0-lipo... lipo
checking for x86_64-apple-darwin15.2.0-nm... /private/tmp/gcc20160131-67124-kpenwb/gcc-5.3.0/build/./gcc/nm
checking for x86_64-apple-darwin15.2.0-ranlib... ranlib
checking for x86_64-apple-darwin15.2.0-strip... strip
checking whether ln -s works... yes
checking for x86_64-apple-darwin15.2.0-gcc... /private/tmp/gcc20160131-67124-kpenwb/gcc-5.3.0/build/./gcc/xgcc -B/private/tmp/gcc20160131-67124-kpenwb/gcc-5.3.0/build/./gcc/ -B/usr/local/Cellar/gcc/5.3.0/x86_64-apple-darwin15.2.0/bin/ -B/usr/local/Cellar/gcc/5.3.0/x86_64-apple-darwin15.2.0/lib/ -isystem /usr/local/Cellar/gcc/5.3.0/x86_64-apple-darwin15.2.0/include -isystem /usr/local/Cellar/gcc/5.3.0/x86_64-apple-darwin15.2.0/sys-include   
checking for suffix of object files... configure: error: in `/private/tmp/gcc20160131-67124-kpenwb/gcc-5.3.0/build/x86_64-apple-darwin15.2.0/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage1-target-libgcc] Error 1
make[1]: *** [stage1-bubble] Error 2
make: *** [bootstrap] Error 2

READ THIS: https://git.io/brew-troubleshooting

These open issues may also help:
brew reinstall gcc --without-multilib error https://github.com/Homebrew/homebrew/issues/48212
brew install gcc --without-multilib stucks during 'make bootstrap' https://github.com/Homebrew/homebrew/issues/48612
gcc: warning: couldn't understand kern.osversion '15.0.0 https://github.com/Homebrew/homebrew/issues/48623
graphicsmagick fails to compile with gcc-5 in superenv https://github.com/Homebrew/homebrew/issues/48402
gcc failed to build on 10.6.8 https://github.com/Homebrew/homebrew/issues/47741
apple-gcc42 takes priority over modern gcc https://github.com/Homebrew/homebrew/issues/41055
gcc causes false alarms in C++ stdlib check https://github.com/Homebrew/homebrew/issues/45218
gcc 4.9.2 fails to produce debugging information https://github.com/Homebrew/homebrew/issues/34976
Object files deleted during build of gcc needed by gdb https://github.com/Homebrew/homebrew/issues/35734
MacOS.(gcc|clang|llvm)_version can return nil https://github.com/Homebrew/homebrew/issues/18781.

To fix this, is there a way to remove GCC completely and then just install it again? Or are there other solutions for this? Please help me!


Answers:


brew unlink gcc should be sufficient to get it off your default path, so you'll be back to Xcode's default gcc (assuming you have that installed). Once you've rebuilt gcc, you can revert the unlinking by running brew link gcc.