Reputation: 3627
I've installed gcc-4.6
using the homebrew-alternatives gcc
formula, but I can't seem to get it to use that GCC to install other formulas. Specifically Open-MPI and boost.
Does anyone know how to make Homebrew use this new compiler?
Thanks!
Upvotes: 15
Views: 15312
Reputation: 6308
It looks like the latest versions of Homebrew now support the HOMEBREW_CC
and HOMEBREW_CXX
environment variables.
So now you can do the following:
$ HOMEBREW_CC=gcc-4.2 HOMEBREW_CXX=g++-4.2 brew install ice
Upvotes: 21
Reputation: 584
These answers are all fairly old now. It seems that recent versions of homebrew have a '--cc' option that enables you to select the c compiler to use. For example
brew install --cc=gcc-6 <package-name>
will install using the brew version of gcc
Upvotes: 12
Reputation: 251
Homebrew can't adapt to other versions of gcc using command line options. You can easily override the older compiler, though, if you edit the open-mpi and boost formula. For example, you can add a few commands after the "def install" in open-mpi.rb:
def install
# Force compilation with gcc-4.6
ENV['CC'] = '/usr/local/bin/gcc-4.6'
ENV['LD'] = '/usr/local/bin/gcc-4.6'
ENV['CXX'] = '/usr/local/bin/g++-4.6'
# Compiler complains about link compatibility with FORTRAN otherwise
ENV.delete('CFLAGS')
ENV.delete('CXXFLAGS')
That worked for me on Lion. Good luck.
Upvotes: 20
Reputation: 33981
From their wiki it sounds like they don't support other compilers:
Installing a custom version of GCC or autotools into the $PATH has the potential to break lots of compiles. So we stick to the Apple-provided compilers.
Upvotes: 2