MacOS – Install gcc to mac via Terminal

gccmacosopen sourceterminal

I have installed Xcode and the command line tools from the Mac Developers website, which I have read a few times is a prerequisite. I also installed the MacPorts program. In terminal:

sudo port install gcc48
sudo port select -set gcc mp-gcc48

All the above went smoothly until I type:

hash gcc

When I press enter, I get the following error message:

-bash: hash: gcc: not found

I am at a loss and do not know how to proceed to successfully install gcc on my Mac (which is running Mac OS X 10.9.1).

Much obliged to any suggestions and or alternatives to installing the gcc

Best Answer

You might be better off installing gcc from homebrew than Macports.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew update
brew search gcc

There're are about 6 versions of gcc available from this package manager. See http://brew.sh for more details on the homebrew tools. Also this thread has more details on gcc and homebrew: How do I install GCC via Homebrew? Lastly, the gcc error in your shell is similar to this thread: I installed Xcode but I still don't have gcc in my terminal