9

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?

1
  • any success? I am looking at how to set Homebrew to use GCC by default
    – Denis
    Oct 18, 2014 at 17:24

1 Answer 1

5

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.