osx - Why is gcc --version giving this error message?

06
2014-06
  • WilliamKF

    When I run gcc --version on my Mac OSX Mavericks with Xcode v5.1 installed it sends to stderr the following error output:

    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
    

    The output to stdout is:

    Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
    Target: x86_64-apple-darwin13.1.0
    Thread model: posix
    

    If I do clang --version the stderr output is no longer there and the stdout is as above.

    Is it okay to invoke clang via gcc and if so, why does it give that error output when invoked as gcc?

    Note the clang and gcc are different inodes although they have the same dates and size, but diff says they differ from each other. Also strings gives "clang" only for clang and nothing for gcc.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    osx - How to add a hand-compiled gcc to gcc_select
  • Charles Stewart

    On an old iBook G4 running Tiger, and which should not be upgraded to Leopard, and which thus cannot be upgraded past XCode 2.5, I would like to compile some packages from source from either Fink or MacPorts, packages which require gcc 4.0.

    I have a perfectly decent gcc 4.0 compiled by hand, but gcc_select, which is used by both Fink and MacPorts to select gcc versions, does not know of their existence, but only of the gcc 3.3 that came with XCode. How do I get gcc_select to acknowledge this compilers existence?

    Answer Following Chris' suggestion, I saw that my gcc_select -n 4.0 found gcc-4.0, but not g++-4.0. Installing XCode 2.5 did the trick.


  • Related Answers
  • Chris Johnsen

    Which gcc_select and gcc are you using? There is one that comes with the system, and one available in MacPorts (I do not use Fink, and I did not find one in their package list). I do not have the MacPorts one installed, but looking at its Portfile, it seems that it is setup to only manage the MacPorts gcc installations (/opt/local/bin/gcc). The system gcc_select manages /usr/bin/gcc.

    The system gcc_select is from the normal Developer Tools (DeveloperToolsCLI.pkg). Using it to select a gcc other than the ones provided by the Developer Tools installations is probably “unsupported”. It might work, but it would require installation into (or at least symlinks in) various "system" directories. Try (e.g.) gcc_select -n 4.9 to see what is says it expects.


    My iBook G4 running 10.4 with the Developer Tools installed has gcc 4.0.1 as the default.

    % gcc --version
    powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5370)
    

    Also, my gcc-3.3 is a different build from yours.

    % gcc-3.3 --version
    gcc-3.3 (GCC) 3.3 20030304 (Apple Computer, Inc. build 1819)
    

    Maybe you have an old and/or incomplete Developer Tools installation. According to the receipts, my gcc-4.0 came from gcc4.0.pkg. Looking in my archive, I have xcode25_8m2558_developerdvd.dmg (946768492 bytes), that I downloaded through the Apple Developer Connection a long time ago.

  • fideli

    Assuming you've installed gcc_select through MacPorts (I'm not sure if it's the same as the one from Apple or from Fink), you should be able to add an entry by navigating to /opt/local/etc/select/gcc. Check out the base file, which will be your reference, and then create a new file which provides corresponding locations to your hand compiled gcc. For example, on my machine:

    $ cat base
    bin/gcc
    bin/cpp
    bin/c++
    bin/g++
    bin/gcj
    bin/gcov
    bin/gfortran
    
    $ cat mp-gcc43 
    bin/gcc-mp-4.3
    bin/cpp-mp-4.3
    bin/c++-mp-4.3
    bin/g++-mp-4.3
    bin/gcj-mp-4.3
    bin/gcov-mp-4.3
    bin/gfortran-mp-4.3
    

    I haven't actually tried this (I'm not really a C coder so I'm afraid to screw things up), but hopefully this helps!

    EDIT
    Another thing: at least for python_select, items in the base file that aren't contained in the select file are replaced with a -.