Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I (more or less) followed the instructions here to install a more recent version of gcc so that I can build ruby on a new machine.

So I now have gcc installed to ~/my_gcc, and the instructions say to access gcc in this location by running

export PATH=$HOME/my_gcc/bin:$PATH

I did this, but am still getting the old gcc when I check the version.

$ gcc -v
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

If I move the gcc in /usr/bin/gcc to gcc_old, I don't get any gcc recognized even though when I echo $PATH the ~/my_gcc/bin path does show up. Should I just copy ~/my_gcc/bin to /usr/bin?

share|improve this question
Did you put that export in your ~/.bashrc? Have you opened a new terminal? (Does echo $PATH show that path?) – Kevin Nov 28 '11 at 18:30
Try which gcc. Are the files you compiled maybe not executable? – Daniel Beck Nov 28 '11 at 18:33

I hacked around this using a previous method (ran into the EXACT same problem) and unfortunately I could not come up with a non hacky solution.. however:

Using which gcc will tell you where the default installed gcc is. Now if I were you, I would move the old gcc to a new directory and create a symbolic link to the new gcc directory in the old directory.

Try gcc -vagain after that.

Sorry for the illegitimate method. I have yet to come up with a clean solution.

+1 to anyone who does if I see it.

Good luck

share|improve this answer
I found a non hacky version, which is that there is a site with dmgs for installing gcc on mac. Not only does it install cleanly, but it doesn't take 2 hours to install (more like 5 minutes). Unbelievably, it is so buried in terms of google results that I can't even find the link to provide here!! Gah, if anyone could add it.. it'd be helpful. – Jeremy Smith Nov 30 '11 at 15:28

If you have followed the procedure described here, you should inquire for my-gcc, my-g++, my-gfortran and so on. The author has purposely added the "my-" prefix in order to not mess up Apple's compilers.

my-gcc -v

should return gcc-4.6.1 or 4.6.2.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .