Often times, you need c or gcc compiler to compile open source projects in Mac OS X. The problem is Mac OS X doesn’t install the gcc compiler by default.

If you try to install or compile some projects that required c/gcc compiler, following errors message will be logged :

configure: error: C compiler cannot create executables
 
configure: error: no acceptable C compiler found in $PATH

In terminal, type “gcc“, you will get message “command not found”.

$ gcc
-bash: gcc: command not found

Solution

To install gcc compiler on Mac OS X, you need to download and install “Command Line Tools for Xcode”, which is available in Apple’s developer page. See following steps :

1. Register Apple Developer Account

Access Apple’s developer page, to process on the download, you need to register an Apple account, it’s free, but need to spend few minutes to fill in the survey.

2. Command Line Tools for Xcode

In Apple developer page, “Developer Tools” category, find “Command Line Tools for Xcode“, choose your version and click on the xx.dmg file (file size is 100mb ++) to start the download.

Apple Developer Download Page

3. Installation

After .dmg file is downloaded, a small dialog will be prompted and show you this file – “Command Line Tools.mpkg“, just double click on it, follow the wizard guide to complete the installation.

install command line tools
install command line tools

4. Verification

After installation is completed, run “gcc -v” in terminal again. If everything fine, following output will be displayed.

mkyong$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: {ignore long text…}
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)

Done, the gcc version 4.2.1 is installed on Mac OS X successfully.

Tags :
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider making a donation to the charity, thanks.

Related Posts

Popular Posts