Install cc in gcc instead of clang on OSX Yosemite

I am trying to get Mac OSX Yosemite to use gcc instead of clang when calling cc, but no matter what I do, it refuses to play. I already tried changing bash_profile / bashrc and even rethinking the symbolic link, but to no avail - every time I call "cc" it still rings, which works. I am trying to make it be gcc instead (and no, just calling gcc is not an option).

Earlier, I asked a similar question ( Make gcc default compiler with Yosemite / disable clang ).

+7
c gcc clang osx-yosemite macos
source share
2 answers

Neither OS X nor Xcode comes with real GCC. For compatibility with scripts that assume the compiler is called "gcc", it has executables under that name, but they are all fronts for Clang. No amount of symbolic links, setting environment variables or setting aliases prevents these executable files from running the real GCC.

If you want GCC, you need to install it. You can do this using one of the package managers, for example MacPorts (the one I am familiar with). I am sure you can also use Homebrew.

You should not change anything in / usr / bin. If you have already done this, you must restore what you changed, if possible.

Well-managed package managers will also not modify this directory. They must be installed in a separate directory, such as / opt / local / bin, / usr / local / bin or the like. In this case, you will want to modify your PATH to place these directories earlier than / usr / bin.

+9
source share

You must not do this. Many tools rely on installation files to indicate what they should. Another option is to set the CC environment variable to gcc and invoke compilation using $CC ... rather than cc ... ; this environment variable will also be raised when creating packages through configure (autotools) or cmake .

This is also a compatible approach with gcc MacPorts versions (e.g. much more relevant gcc-4.9.2), which can be configured using sudo port select --set gcc mp-gcc49

+6
source share

All Articles