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 :
- 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: 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 :
- Register Apple Developer Account : Go to Apple Developer Login page and register your account or login with our existing account details.
- 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.
- 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.
- 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 -->
- Open XCODE 4.3 and above
- Click Xcode-->Preferences
- Click on Download Tab --> Component --> Check and Install Now
- In list select Command Line Tools and Install.
Done ....
Keep coding .... :)
Comments
Post a Comment