Since I installed gcc-49
on my Mac I can't get Homebrew to find the C++ compiler anymore. It always fails with error messages like:
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
Running "brew upgrade -v" spits out this:
...
==> ENV
HOMEBREW_CC: llvm-gcc
HOMEBREW_CXX: llvm-g++
...
I have no idea why Homebrew wants to use these compilers. Why can't it use the normal CC/CXX environment variables like everything else?
I already found, that by editing the formula directly like described in Using Homebrew with alternate GCC, I can change the HOMEBREW_CXX
to use /usr/local/bin/g++
for example, which makes compiling formulas that need C++ work again.
But I don't want to edit every single formula by hand for the rest of my days. How can I change this HOMEBREW_CXX
environment variable permanently? I tried setting them in my .bash_profile and running "export HOMEBREW_CXX=..." in the console and neither of those work, only editing the formula directly.
Does anyone have an idea?
A poor man's solution, to be sure, but this works: put an alias in your .bashrc
or .bash_profile
:
alias brew='HOMEBREW_CC=gcc-4.8 HOMEBREW_CXX=g++-4.8 brew'
Now, whenever you use brew
it will use the compilers you want. Check that it works by doing:
brew --env
HOMEBREW_CC: gcc-4.8
HOMEBREW_CXX: g++-4.8
...
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With