Installing a GCC/G++ for my mac OSX 10.8

06
2014-06
  • Ash

    My problem is simple, I would like to get the OSX/BSD version of the GCC and G++ compilers from the GNU.org website. However after some research (as described below) I learned that Apple uses LLVM and gcc is a symbolic link to llvm-cc while g++ is a symbolic link to llvm-g++.

    I also learned Apple were stupid enough to remove these compilers with no reasonable explanation (Literally, nobody can give a valid reason for this, there is no such thing). The other thing I learned is Apple uses the LLVM (as previously explained).

    • I have searched the web to try and learn how to do this, and nothing is being useful. Only people talking about Xcode, or other long-winded installing of Apps and running commands and installing other resources.

    • XCODE is NOT the solution i'm looking for as Xcode does not automatically come with the compiler, but requires additional installations and things.

    My question

    • I want to learn, I want to understand;
    • I do NOT want the "easy way" or the "use the application way";
    • I want to do it the old-school way, the download source from GNU, configure/make/make install - funnily enough, Apple has removed these too - What are they thinking?

    My current attempt

    I downloaded the LLVM source from the following location: Source: http://llvm.org/releases/download.html#3.3 Download: Clang Binaries for Mac OS X (79M) (.sig)

    I then extracted the contents of this directory, in my Downloads directory: $ tar -xzpf clang+llvm-3.3-x86_64-apple-darwin12.tar.gz

    I have tried to read the Getting Started Guide, which says 'Read the documentation' I cannot find this documentation, not in the downloaded libraries or online.

  • Answers
  • beroe

    Apple has changed the way that this works now (you don't have to install all 1.7 GB of XCode).

    If you are willing to register for a free developer account, you can get just the command-line tools installer from http://developer.apple.com/downloads


  • Related Question

    osx - Installing ruby from source and having a problem with gcc
  • lillq

    I am trying to follow this guide Compiling Ruby, RubyGems, and Rails on Snow Leopard and I am running into a configuration issue.

    After downloading and extracting the source, I am running a command to set up some configuration.

    This is the output that I am given:

    my-macbook-pro:ruby-1.9.1-p243 lillq$ ./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
    checking build system type... i386-apple-darwin10.0.0
    checking host system type... i386-apple-darwin10.0.0
    checking target system type... i386-apple-darwin10.0.0
    checking for gcc... gcc
    checking for C compiler default output file name... 
    configure: error: in `/Users/lillq/src/ruby-1.9.1-p243':
    configure: error: C compiler cannot create executables
    See `config.log' for more details.
    

    Note: The first time I ran this it could not find gcc. To fix this I added to my path /Xcode3.1.4/usr/bin and sbin.

    Then I decide to check whether I could compile code. (Its a new computer, I havent compiled on it before and I recently installed Xcode)

    my-macbook-pro:~ lillq$ gcc test.c
    test.c:1:19: error: stdio.h: No such file or directory
    test.c: In function ‘main’:
    test.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
    

    Hmm...

    I thought that Xcode is suppose to install the compilers correctly for me. Is there something I am missing/doing wrong?

    Thanks-


  • Related Answers
  • kartikmohta

    During XCode install, there is an option to also install the tools at the standard unix locations (binaries in /usr/bin, include files in /usr/include etc.). Did you choose that option during the installation?

    I guess the error is because the compiler searches those standard paths for the header files (and also the standard libraries) and is not able to find them.