Change GCC version on Mac OSX Lion

1

I'm currently running GCC 4.2. I would like to switch to a more recent version.

I have Homebrew and I have MacPorts for package management. I've followed several tutorials today for installing a newer version of GCC, but everytime I get finished and type gcc -v and I still get that I'm using 4.2. How can I switch this? If you need more info let me know, I'm pretty new to system packages.

Donny P

Posted 2013-09-22T23:26:06.433

Reputation: 111

Why do you want gcc, what stops you using Apple's clang? – user151019 – 2013-10-24T11:33:35.233

Answers

0

Just a quick question: do you properly set the PATH environment variable, i.e. put the path of newer version of GCC (you just installed) before the path of GCC 4.2 (maybe the system default), so that when your operating system looks for needed executable, it will find the newer version first?

phe0113

Posted 2013-09-22T23:26:06.433

Reputation: 161

I do not, where can this be done? Some places mention a ".profile", which I believe in Mac OSX Lion is my ".bash_profile". If this is the correct file, what is the syntax for adding it? If it is not the correct file, where can I add this PATH environment variable? – Donny P – 2013-09-23T00:04:12.103

0

As far as I know, Homebrew installs gcc with version suffix. For example I have gcc 4.8 installed and it is available as gcc-4.8. Try to check if you have the same pattern of files.

eiennohito

Posted 2013-09-22T23:26:06.433

Reputation: 547

Thanks for the answer @eiennohito, yes it does install with a version suffix. How can I make my Mac use this newer version instead of the old gcc 4.2? – Donny P – 2013-09-23T04:11:21.157

If you want to compile something yourself do the CC=gcc-4.8 CXX=g++-4.8 ./configure then make as usual. – eiennohito – 2013-09-24T04:27:24.853