Mac OS X Install GCC Compiler

Compiling open source projects typically requires a C compiler and GCC is typically the compiler of choice. Mac OS X does not install the GCC compiler by default, but it is freely available in the xcode suite of development tools.


To install the GCC compiler, download the xcode package from http://connect.apple.com/. You will need to register for an Apple Developer Connection account. Once you have registered, login and click Download Software and then Developer Tools. Find the Download link next to Xcode Tools (version) – CD Image, and click it.

Find the downloaded package, double click it, and follow the installation instructions to install GCC and a host of other development applications. The GCC compiler will be located at /usr/bin/gcc.

Websites tend to change over time, so if you notice that the steps to download xcode have changed, please post a comment. I will update the tech-recipe. For example, Steve posted (and Jim Daniel confirmed) that you can download the GCC for 10.6 and 10.7 directly from kennethreitz on github. See comments for the latest link.

The Conversation

Follow the reactions below and share your own thoughts.

72 Responses to “Mac OS X Install GCC Compiler”

  1. October 10, 2008 at 4:46 am, bogus dude said:

    What if I’m still running Tiger, but the only download I see is for Leopard? The PDF says that the version listed is for Leopard only.

    Reply

    • October 10, 2008 at 4:51 am, Quinn McHenry said:

      Keep looking down the list.. you’ll need a version 2.x of the developer tools. Like this:

      Xcode 2.5 Developer Tools
      Xcode 2.5 is an update release of Xcode developer tools, providing bug fixes over Xcode 2.4.1. Xcode 2.5 can be installed on Tiger (Mac OS X 10.4) or on Leopard (Mac OS X 10.5).

      Reply

      • July 19, 2011 at 5:30 pm, Mem4sports said:

        Quinn can you convert on a mac a doc that looks like a page which should really be a zip file?

        Reply

        • November 27, 2012 at 9:07 am, Honesty said:

          Q: The first time I build my program with Code::Blocks I get the following error message: “…uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?! Skipping… Nothing to be done” What’s wrong?

          Reply

    • October 14, 2008 at 9:42 pm, math said:

      Keep searching, IT IS there. I went into the same issue, the default xcode that appear in the page is 3.x, but you need 2.5, it’s the latest for Tiger.
      I searched in the site in the developer tools section, yeah I know it’s annoying.

      Reply

  2. November 21, 2008 at 3:41 pm, P said:

    Apple sucks 1GB download for GCC

    Reply

    • March 01, 2009 at 11:08 pm, Q said:

      word

      Reply

      • July 29, 2012 at 2:56 pm, leo said:

        Thank you very much for your advice.

        Reply

    • May 23, 2009 at 6:37 pm, thatguy said:

      GCC-4.0 requires 95mb when installed from your OS X DVD.

      Reply

  3. January 08, 2009 at 2:07 pm, buy youtube views said:

    thanks for sharing the web addresses. this will help a lot.

    Reply

  4. January 14, 2009 at 7:01 pm, Mahesh Gupta said:

    thank u very much…….

    Reply

  5. January 14, 2009 at 7:08 pm, Mahesh Gupta said:

    May be better download iphone SDk 2.2 which has Xcode in it. size is 1.56GB.:-)

    Reply

  6. March 01, 2009 at 5:58 pm, Rich Feit said:

    Thanks much! Minor change — you first click on “Mac OSX”, then there’s XCode Tools in the resulting list.

    Reply

  7. March 07, 2009 at 4:17 am, Anonymous Coward said:

    srsly? 1+GB for freaking gcc? that is RIDIC!

    Reply

  8. March 17, 2009 at 2:54 pm, Ali said:

    Hi,
    Thanks for the instructions. The path has changed slightly.
    Once you log in, go to: Downloads -> Developer Tools -> Xcode 3.1.2 Developer Tools and download the package called Xcode 3.1.2 Developer Tools DVD (Disk Image)

    Cheers!

    Reply

  9. April 04, 2009 at 2:04 am, Liftchair said:

    The ‘gcc compiler’ is installed when one installs ‘XcodeTools’ (via the ‘XcodeTools.mpkg’ file) from the installation CD (if installing Panther [MacOS X 10.3.x] or earlier) / DVD – in the ‘/Xcode Tools/’ folder.

    Or, in the CDs’ / DVDs’ ‘/Xcode Tools/Packages/’ folder is / are the ‘gccx.x.pkg’ (where s.x is the version number) installer file(s).

    Reply

  10. April 30, 2009 at 8:45 am, denver real estate said:

    I like the Apple sucks for 1GB download for GCC. It is really good. Try!

    Reply

  11. May 23, 2009 at 6:36 pm, thatguy said:

    GCC-4.0 requires 95mb when installed from your OS X DVD.

    Reply

  12. June 21, 2009 at 4:00 pm, Witek said:

    Some Apple forum members managed to figure out that the most up to date and final release of Xcode for Tiger is v 2.5. You can find the link to the Xcode package at http://discussions.apple.com/message.jspa?messageID=7769749

    Reply

  13. July 05, 2009 at 5:57 pm, J.C. said:

    Sorry if i am repeating anyone but I know if you have mac 10.4.X then on the install disk you can find a copy of xcode…

    Reply

  14. July 05, 2009 at 5:59 pm, J.C. said:

    Opps I didn’t see lift chair…
    “The ‘gcc compiler’ is installed when one installs ‘XcodeTools’ (via the ‘XcodeTools.mpkg’ file) from the installation CD (if installing Panther [MacOS X 10.3.x] or earlier) / DVD – in the ‘/Xcode Tools/’ folder.

    Or, in the CDs’ / DVDs’ ‘/Xcode Tools/Packages/’ folder is / are the ‘gccx.x.pkg’ (where s.x is the version number) installer file(s).”
    Sorry

    Reply

  15. August 19, 2009 at 7:35 am, R said:

    Hi,
    I’ve been installed the powerpc-apple-darwin9-gcc-4.0.1. I’m now concerned with an error message from typing ‘gcc -Version’ into console:

    ”powerpc-apple-darwin9-gcc-4.0.1: couldn’t run ‘/usr/bin/powerpc-apple-darwin9-gcc-ersion’: No such file or directory”

    This seems to be obvious, because the letter ‘v’ from version is missing. But where have I look at to correct this mistake ?

    Reply

  16. August 19, 2009 at 12:52 pm, kingman said:

    The GNU Compiler for Java (GCJ or gcj), a free software compiler for the Java programming language, forms part of the GNU Compiler Collection…. The GNU Compiler Collection is a full-featured ANSI C compiler..
    lift chair recliners

    Reply

  17. August 19, 2009 at 1:30 pm, Anonymous said:

    This article provides an overview of the GNU Compiler Collection (GCC) from the Free Software Foundation and its use on Mac OS X… very useful blog and i love this article a lot..
    lift chairs

    Reply

  18. October 16, 2009 at 7:36 am, José Borges said:

    I have an Mac with OS a version 10.5.8. I recently installed Xcode v3.1.3 and I started to get errors and warnings in compiling programs with gcc, such as:
    ” ….. incompatible implicit declaration of built-in function ‘ceil’ ”
    Can someone help me?

    Reply

  19. November 06, 2009 at 1:11 pm, Anonymous said:

    thank you for writing this helpful notes.
    Can you tell me how to install CGAL in MAC

    Reply

  20. November 07, 2009 at 12:24 am, Kurt Bigler said:

    As a long-time XCode user it has been installed on my Mac for years, and I have applied updates occasionally. Nonetheless gcc is not located at /usr/bin/gcc (which has not been an issue until now since I don’t normally use the command line for compiling). It is however, located at /Developer/usr/bin/gcc. So I added /Developer/usr/bin/gcc to my path, hoping that would let me use gcc and make to build libjpeg under Leopard. (Aside: Apple’s own jpeg support via “Image IO” appears to ignore the specified “quality” for jpeg compression).

    However the ./configure script for libjpeg says:

    configure: error: installation or configuration problem: C compiler cannot create executables.

    But at least now that I altered my $PATH it recognizes that gcc is present.

    I have not tried to debug the configure script, but figure I am missing something basic, or else XCode installation practices have changed. My XCode is 3.1.1, and gcc from the command line says “i686-apple-darwin9-gcc-4.0.1″.

    Reply

    • November 07, 2009 at 8:11 am, Kurt Bigler said:

      FIXED: I installed XCode 3.1.4 and it resolved the problem. It also installed gcc in /usr/bin so I no longer have to alter my $PATH.

      Reply

  21. November 14, 2009 at 10:26 pm, Areej said:

    hello
    do you know how to install ns-2.34 on mac os 10.5.5
    I all ready have XCODE 3.1.1
    thnx ,

    Reply

  22. November 23, 2009 at 4:17 am, lift chairs said:

    This article provides an overview of the GNU Compiler Collection (GCC) from the Free Software Foundation and its use on Mac OS X… very useful!

    Reply

  23. December 03, 2009 at 8:45 pm, Anonymous said:

    well done.
    For more jobs visit http://www.staffingpower.com

    Reply

  24. February 05, 2010 at 2:17 am, AMIT RAUT said:

    RUN / CONSOLE OPTIONS ARE UNAVAILABLE FOR ANY FILE CREATED
    PLZ HELP ME WHAT SHOULD I DO??????

    Reply

  25. April 05, 2010 at 3:01 am, Anonymous said:

    As of April 4th 2010:
    Once logged into connect.apple.com, click Developer Tools, then click Xcode 3.2.1 Developer DVD (Disk Image)

    Reply

  26. May 19, 2010 at 10:15 pm, isak said:

    same address – but the topic is called “Xcode 3.2.2 Developer Tools” and it is called Disc Image, not CD Image.

    Reply

  27. June 26, 2010 at 1:51 pm, Anonymous said:

    someone have recompiled for Mac OS X Leopard?

    Reply

  28. August 01, 2010 at 7:59 pm, of mesothelioma said:

    I have an important question. You mentioned that you chose to ignore ring settings in this paper enigma machine. I have been trying to get the ring settings working by cutting each paper strip in half and shifting the right side by the appropriate ring offset..eg to the 2nd position if the ring is B offset. If all the examples have a GAAA and RAAA setting, I get the paper enigma to match the enigma simulators, but if I try any ring offset, the results don’t match. I went to the rotor details in Wikipedia and tried to replicate their results with GAAA and RBBB to get EWTYX to no avail. Could you please help tell me how you would get this to work right if I cut your strips in half and rotate 6 different rings instead of 3?

    Reply

  29. August 10, 2010 at 6:11 pm, Sprintox said:

    This is retarded. 1 GB for a gcc compiler?

    Reply

    • February 18, 2011 at 4:28 pm, sam said:

      It’s not just a gcc compiler, it’s a whole development package including many other applications.

      Reply

  30. August 24, 2010 at 3:03 pm, cari said:

    Is there any way to download a mac compiler with having an account with Apple? Because it is $100 a year. I just dropped my account because I felt like that was way too much money to spend every year for what Apple offers you. Plus If I get an account and download the compiler, if I don’t renew my account I think the compiler will stop working just like my email stopped working.

    Reply

    • August 25, 2010 at 1:47 pm, Morphenius said:

      Apparently it’s possible to become a developer without signing up for any of their programs. Becoming a developer is free, and at that point you can download Xcode.

      Reply

  31. September 10, 2010 at 4:51 pm, Asdf said:

    I hate this because I dont want to install xcode. I just want gcc. Xcode is a >2gigs .dmg (with the ios sdk) when gcc is much smaller. It’s pretty ridiculous when you have to install unnecessary and unwanted things to get a basic staple of computer programming.
    This is why apple is awful. I do not want your IDE, I most certainly do not want the bundled iphone SDK (and I cannot find a non-bundled version from apple’s dev. site). I just want gcc (which should come with osx by default).
    Sorry but osx is for children with over-protective children.

    Reply

    • September 10, 2010 at 6:00 pm, Asdf said:

      whoops

      *sorry, but osx is for children with over-protective parents

      Reply

      • October 23, 2010 at 7:10 pm, Jnkm 89 said:

        you can get gcc from their website ( http://gcc.gnu.org/ ) and install it yourself. downloading xcode is just one way to get it installed on your computer. Learn how to use the web before make these ignorant/moronic comments.

        Reply

        • November 21, 2010 at 9:40 am, Stuck said:

          how do you install it on mac from the website?

          Reply

  32. September 20, 2010 at 1:37 am, George Jost said:

    I just installed it. I’m frustrated. I installed the package, it told me location is “Mac Harddisk”. That doesn’t give me a path. In theory, it should be in /usr/bin?

    Nothing is there. It claimed to copy over 93 MB but didn’t do anything? How can I tell if this was actually installed?

    Reply

  33. May 01, 2011 at 10:38 pm, keshav said:

    i just installed xcode from the above url. The install was successful but I can’t find gcc binary. Is it under a different name? I’m running OSX 10.5.8

    Reply

  34. June 24, 2011 at 9:26 pm, Toltmanns said:

    It looks like apple is forcing us to pay $100 to get this xcode software, is there another way?

    Reply

    • June 25, 2011 at 9:36 pm, Rebegol said:

      I had a lot of trouble with this today — only since xcode 4 came out is xcode 3.0 no longer available (it was free). You can pay about $5 for Xcode 4. However, your installation disk will have the right version of xcode for your operating system on it (for free). I upgraded to Snow Leopard and on the install disk, Xcode is an optional feature that does not install unless you ask it to.So look to the disk rather than the internet — I couldn’t find xcode free anywhere.

      Reply

  35. September 03, 2011 at 7:51 pm, Allen Liu said:

    I had the same issue of installing xcode but still could not find GCC. Try searching for “install xcode” through Spotlight and run that first file. That should do it. Took me a while to figure it out. Hope this helps!

    Reply

  36. September 13, 2011 at 5:33 pm, tokeiten said:

    Try:
    /Developer/Applications/Xcode

    it works beautifully !

    Reply

  37. September 13, 2011 at 5:43 pm, tokeiten said:

    if what you want, is not the Xcode IDE but just the plain compiler type:

    gcc filen_name -o output_file_name

    or try:

    man gcc

    good luck!

    Reply

  38. January 16, 2012 at 2:59 pm, Kebman said:

    Does not work. You have to pay to download Xcode. I still need GCC, tho.

    Reply

  39. January 16, 2012 at 3:03 pm, Kebman said:

    My bad, seems to work now. :p Had some problems downloading Xcode for older OS X’es.

    Reply

  40. February 19, 2012 at 10:33 pm, Alex said:

    Thank you very much, this is exactly the info i needed.
    Appreciated.

    Reply

  41. March 22, 2012 at 4:25 am, Steve said:

    https://github.com/kennethreitz/osx-gcc-installer

    Has links to just download GCC for 10.6 and 10.7

    Reply

    • August 07, 2012 at 7:26 am, greyfaerie4 said:

      Thank you!>

      Reply

    • September 04, 2012 at 7:38 am, Mike said:

      The version from github saved me a lot of time… just neededd gcc and I did not want the system upgrade. Thanks guys!

      Reply

  42. April 02, 2012 at 1:40 pm, Jim Daniel said:

    Dude, move the last comment to the top (sticky it)! This is exactly what I needed and it works perfectly!

    Reply

  43. April 03, 2012 at 4:01 pm, foo said:

    Apple sucks big time!

    Reply

    • August 07, 2012 at 7:27 am, greyfaerie4 said:

      WHY????>

      Reply

  44. August 22, 2012 at 4:25 am, Sculptor said:

    I don’t want to pay Apple a nickel for gcc! That would be subverting to whole purpose of gcc. How do a get a free download?

    Reply

    • September 11, 2012 at 1:34 pm, MacManux said:

      ??? XCode is a free download

      Reply

      • November 30, 2012 at 4:27 pm, Kevin Grittner said:

        It seems to be insisting on a credit card number, security code and all, to let me do the free download. I’m not going to put a credit card number into App Store. Period. Ever. Is there any other way to get gcc for OS X? If not, I guess I’ll just support Linux, Windows, HP/UX, AIX, etc., and forget OS X.

        Reply

  45. September 12, 2012 at 10:49 am, kim said:

    I have downloaded gcc compiler.. how do I go about using the c++ programming?

    Reply

  46. October 03, 2012 at 6:08 pm, Ted Yu said:

    I am using OSX 10.7.5
    I downloaded xcode312_2621_developerdvd.dmg and from there I installed gcc4.0.pkg
    But I still cannot find where gcc was installed.

    Did I install the correct package ?

    Reply

  47. October 06, 2012 at 11:21 pm, Rishabh said:

    Hi,

    I have XCode downloaded for a while, yet I do not have access to GCC. Help?

    Reply

    • December 09, 2012 at 1:45 am, Daniel B said:

      The procedure has changed slightly, as the package name is different now. Note to everyone: Xcode is *free* now. As in, no need to pony up $$$. Didn’t get asked for CC info either (though I do have an iTunes acct and probably that’s why).

      Get it from the App Store (as I said, free) and after downloading/installing, you need to go to Xcode -> Developer Tools -> More Developer Tools

      The package name is now called Command Line Tools (OS X version name) for Xcode – (release date)
      The site might ask you to register as a developer before showing up the list.

      Reply

  48. November 19, 2012 at 10:38 pm, Nate said:

    I think the website changed

    Reply

  49. December 23, 2012 at 6:16 am, Howard said:

    Xcode 4.3 changes all this. Searched the Documentation, and it says:
    “The command-line tools are not bundled with Xcode 4.3 by default. Instead, they can be installed optionally using the Components tab of the Downloads preferences panel …”

    Also, since I saw the reference to /Developer in another comment, I should point out it goes on to say:
    “/Developer No Longer Exists
    The simplification afforded by repackaging Xcode 4.3 as a single app bundle eliminates the need for the /Developer directory containing prior versions of Xcode….”

    Reply

  50. May 11, 2013 at 3:35 am, drew said:

    Going from Linux to OSX is painful. Takes two seconds to install GCC in any Linux Flavor.

    Reply

  51. October 03, 2013 at 12:20 pm, LJ said:

    http://gcc.gnu.org

    this is the website for the open source compiler, small download, heaps of instruction, and best of all: it works! LOL
    xcode may be good for learning, with all the pretty colours, but it ends up being distracting, thus slows down the coding process – at least for me anyhow.
    xcode can easily be replaced by a terminal window and text editor.
    much simpler, just a little discipline with regard to learning syntax and developing your own individual coding style.

    hope the website helps :)

    Reply

  52. February 21, 2014 at 5:09 pm, Geeticka said:

    You could go to the terminal, type GCC and your mac will tell you that you do not have gcc but will ask you if you want to download the xcode

    Reply

Leave a Reply