iDev: How to install GCC Compiler on Mac OS-X?

How to install GCC Compiler on Mac OS-X?

Problem Description:
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 :
1. configure: error: C compiler cannot create executables
2. 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: First Way –>
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 : Go to Apple Developer Login page and register your account or login with our existing account details.
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.
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.
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.

Solution: Second Way –>
1. Open XCODE 4.3 and above
2. Click Xcode–>Preferences
3. Click on Download Tab –> Component –> Check and Install Now
4. In list select Command Line Tools and Install.

Done …. Keep Coding 🙂

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s