Installing Xcode to obtain a C compiler for OS X

If you need a C compiler for a Mac OS X system, you can obtain one from Xcode - What's New - Apple Developer. You can download the Xcode software for free from Apple's website. As of November 20, 2015, the current release is Xcode 7.1, though you can also obtain Xcode 7.2 beta 4 pre-release from the site.

When I attempted to install that version of the software on a MacBook Pro running OS X 10.8.5, aka "Mountain Lion", I was presented with the message below:

We could not complete your purchase.

Xocde can't be installed on "Macintosh HD" because OS X version 10.10.5 or later is required.

The software was free, but, because the operating system on the MacBook Pro I was using was 10.8.5, I couldn't install it and no option was presented to allow me to obtain a prior version of Xcode that would work with OS X 10.8, aka "Mountain Lion". A Google search provided me with the Downloads for Apple Developers web page where I could find previous versions of the Xcode software. I found Xcode 6.3.1 there immediately, but the OS version required for that version of Xcode was not revealed there. Another Google search yielded a posting by Chris Upjohn:

Sadly Xcode 5.1.1 is the latest version you can get for OS X Mountain Lion due to library dependency requirements, you can login using your Apple ID at the below link and simply search for Xcode 5.1.1.

https://developer.apple.com/downloads/index.action

I was able to download Xcode 5.1.1.dmg, which is 2.1 GB in size, by searching from the referenced web page. The description for Xcode 5.1.1 is as follows:

The [sic] is the release version of the complete Xcode developer toolset for Mac, iPhone, iPod touch, and iPad. It includes the iOS 7.1 SDK, OS X 10.9 SDK and OS X 10.8 SDK. Xcode 5.1.1 requires OS X Mavericks or OS X Mountain Lion.

Xcode 5.1.1, which has a release date of April 9, 2014, was the last Xcode release prior to version 6. For further information on the Xcode software, including the various Xcode version, see the Wikipedia Xcode article. I had installed Xcode 3.1.3 on a MacBook Pro laptop several years ago to obtain a gcc compiler - see Installing gcc under OS X. According to the Wikipedia article, though:

Up to Xcode 4.1, the Xcode suite included a modified version of the GNU Compiler Collection. In Xcode 3.1 up to Xcode 4.6.3, it included the llvm-gcc compiler, with front ends from the GNU Compiler Collection and a code generator based on LLVM (which originally stood for Low Level Virtual Machine - see the LLVM article for clarification on this). In Xcode 3.2 and later, it included a code generator based on Apple's LLVM Compiler, and the Clang Static Analyzer. Starting with Xcode 4.2, the Apple LLVM Compiler became the default compiler, Starting with Xcode 5.0, LLVM was the only compiler provided.

To install the software, I double-clicked on the downloaded image file, then dragged the Xcode icon in the Xcode window into the Applications folder in that window, which opened the Applications folder in the OS X Finder application.

Xcode install window

The first time you double-click on the Xcode application in the Applications folder, you will be asked to accept the Xcode and iOS SDK License Agreement.

Xcode License Agreement

Click on the Agree button to accept the license agreement; you will then be prompted for the password for an account on the system that has administrator level access to the system. After you provide it, the installation of Xcode components will then commence.

Xcode installing components

When the installation of the components is complete, you will see a Welcome to Xcode window.

Xcode Welcome

To be able to compile source code from the command line, aka shell prompt, e.g., from a Terminal window, you can use the gcc utility provided by the Xcode installtion. You can see the location of gcc and make using the xcrun command.

$ xcrun -find gcc
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc
$ xcrun -find make
/Applications/Xcode.app/Contents/Developer/usr/bin/make

To install gcc in a location where you can just type gcc to run it without specifying the path to the directory where it is installed, click on Xcode at the top, left corner of the Xcode menu bar, then select Preferences.

Xcode Preferences

Click on the Downloads option and then click on the downward pointing arrow to the right of Command Line Tools.

Xcode Downloads

That will start the download of the command line tools.

Xcode Command Line Tools download

Once you see the check mark next to Command Line Tools, then you can run gcc or make from a command line interface (CLI), such as a Terminal window, by just typing the commands.

Xcode Command Line Tools installed

You can see their locations by using the which command.

$ which gcc make
/usr/bin/gcc
/usr/bin/make

References:

  1. Xcode 4.4 and later install Command Line Tools
    Asked: February 17, 2012
    Stack Overflow

 

TechRabbit ad 300x250 newegg.com

Justdeals Daily Electronics Deals1x1 px

Valid HTML 4.01 Transitional

Created: Friday November 20, 2015