Is there a way to change the compiler to gcc from clang? I have the command line tools installed and am trying to use the terminal to compile instead of xcode itself.
Asked
Active
Viewed 7,729 times
3
-
As of Xcode 5 no gcc based compiler is installed as part of Xcode. With Xcode 4 I believe they had gcc alias to llvm-gcc. You have to either use an old version of Xcode or install gcc yourself. – bames53 Sep 24 '13 at 21:28
-
I have Xcode 4, but I don't know how to switch which compiler to use. By default it is using clang. – user1698555 Sep 24 '13 at 22:48
-
What command are you running? – bames53 Sep 24 '13 at 23:17
-
I use make. But when I type that in it says that clang doesn't recognize some of my flags, so it doesn't link correctly. – user1698555 Sep 24 '13 at 23:42
2 Answers
4
For MacPorts use:
port select --set gcc <group>, <version>
. . as detailed in this answer.
For Homebrew use:
Brew link and brew unlink the package versions that you prefer to use. Note that an "unlinked" package is still installed and usable from /usr/local/opt//, it's just not in the default path.
Community
- 1
- 1
Jasper Blues
- 27,820
- 20
- 98
- 179
-
You do not need to open a new Terminal, you can refresh the profile using `. ~/.profile` – OLL Dec 17 '13 at 14:42
-
Do not do either of these things. If you use mac ports use "port select --set gcc" This is referenced here https://trac.macports.org/wiki/UsingTheRightCompiler . – Jonathan Lisic Jun 02 '14 at 04:01
3
You can install gcc using any ports system (e.g., MacPorts, http://www.macports.org/)
Ilya Verbin
- 637
- 5
- 19