0

This one is driving me crazy:

I need to use lot of stuff which simply does not compile with the standard clang/llvm compilers which come with Xcode 5 (on Mac OS X 10.8), so I decided to install gcc47 via brew.

Everything went fine but when I try to compile things, I get several error messages and I discovered that some includes are still coming from "/usr/include/c++/4.2.1", which is really weird.

Can anyone explain me how to set it up in a clean way?

These are the step I was doing:

  • brew update
  • brew install gcc47
  • alias gcc='gcc-4.7'

brew warned me that I have to set up LDFLAGS and CPPFLAGS, quoting (summarised):

  This formulas are keg-only: so they were not symlinked into /usr/local.
    Conflicts with gmp, mpfr, libmpc, ppl in main repository.

    Generally there are no consequences of this for you. If you build your
    own software and it requires these formulas, you'll need to add to your
    build variables:
        LDFLAGS:  -L/usr/local/opt/gmp4/lib
        CPPFLAGS: -I/usr/local/opt/gmp4/include

        LDFLAGS:  -L/usr/local/opt/mpfr2/lib
        CPPFLAGS: -I/usr/local/opt/mpfr2/include

        LDFLAGS:  -L/usr/local/opt/libmpc08/lib
        CPPFLAGS: -I/usr/local/opt/libmpc08/include


        LDFLAGS:  -L/usr/local/opt/ppl011/lib
        CPPFLAGS: -I/usr/local/opt/ppl011/include

        LDFLAGS:  -L/usr/local/opt/cloog-ppl015/lib
        CPPFLAGS: -I/usr/local/opt/cloog-ppl015/include

So exporting LDFLAGS and CPPFLAGS via

        export LDFLAGS="${LDFLAGS} -L/usr/local/opt/gmp4/lib -L/usr/local/opt/mpfr2/lib -L/usr/local/opt/libmpc08/lib -L/usr/local/opt/ppl011/lib -L/usr/local/opt/cloog-ppl015/lib"

        export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/gmp4/include -I/usr/local/opt/mpfr2/include -I/usr/local/opt/libmpc08/include -I/usr/local/opt/ppl011/include -I/usr/local/opt/cloog-ppl015/include"

should do the trick (I thought).

But it doesn't. I keep getting messages like:

/usr/include/c++/4.2.1/bits/stl_vector.h:600:7: note: must qualify identifier to find this declaration in dependent base class push_back(const value_type& __x) ^

and I simply don't understand why?

3
  • Where would the compile get the include for vector from - the not is just for those 5 libraries and not the standard libraries - you need to set that explicitly
    – mmmmmm
    Commented Nov 27, 2013 at 16:28
  • 1
    @Mark Ah ok, so just add the path of the standard libraries/includes to LDFLAGS and CPPFLAGS?
    – tamasgal
    Commented Nov 27, 2013 at 16:41
  • edit the makefile to point to the homebrew gcc, do not make aliases. Commented Mar 18, 2018 at 12:06

1 Answer 1

1

That note just refers to the 4 libraries gmp, mpfr, libmpc, ppl and I think means that if you use them they need to be before the standard search path.

Your issue is where is the compiler looking for standard library headers (and later libraries). gcc defaults to /usr/include which is installed for Apple's compilers and that gets redirected by version to the path you see.

You need to explicitly set the paths to look in the homebrew compilers path first

2
  • Do you mean setting LDFLAGS and CPPFLAGS or are there any other variables I should check?
    – tamasgal
    Commented Nov 27, 2013 at 17:14
  • Try doing a simple Hello World app first - then get that working - otherwise we might need to see the whole makefile - Are yiu sure you can't use clang - it might be worth asking on SO if you have a particular issue
    – mmmmmm
    Commented Nov 27, 2013 at 23:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .