Mac OS X: Install GCC Compiler with Xcode

I have Mac OS X Mountain Lion. I need to compile a few apps and Perl modules. Then I already installed Xcode from app store but I’m unable to find gcc compiler or make command. How do I install gcc on Mac OS X 10.8.x?


Xcode includes command line development tools such as gcc and friends.

Step #1: Install Xcode on a Apple Mac OS X

First, make sure Xcode is installed. If it is not installed on OS X, visit app store and install Xcode.

Fig.01: Make sure Xcode developer tools are install OS X

Step #2: Install gcc/LLVM compiler on OS X

Once installed, open Xcode and visit:

Xcode menu > Preferences > Downloads > choose  Command line tools  > Click  Install  button:

Fig.02: Installing gcc compiler on Mac OS X


Xcode will download package and install copies of the core command line tools and system headers into system folders, including the LLVM compiler, linker, and build tools.

Step #3: Verification

Open a terminal app and type the following commands:

$ gcc –version

$ whereis gcc

$ whereis make


Sample outputs:

Fig.03: Verify gcc compiler installation on Mountain Lion OS X

Testing sample “Hello world” C program

Create a text file called a.c as follows using a text editor such as vi or cat command:

/* a.c – demo for os x */


int main(void){

printf( Hello world\n );

return 0;


To compile, enter:

$ make a


Run it as follows:

$ ./a


Sample outputs:

Fig.04: Compiling and running sample “Hello world” C program on Mountain Lion 10.8.4

See also

And, there you have it, the gcc version 4.2.1 installed and working correctly on the latest version of Mac OS X 10.8.4. In Apple’s version of GCC, both cc and gcc are actually symbolic links to the llvm-gcc compiler. Similarly, c++ and g++ are links to llvm-g++. For more information and examples see the following man pages:

$ gcc(1)

$ make(1)


This entry is 5 of 13 in the Linux GNU/GCC Compilers Tutorial series. Keep reading the rest of the series:

Ubuntu Linux Install GNU GCC Compiler and Development Environment

Debian Linux Install GNU GCC Compiler and Development Environment

CentOS / RHEL 7: Install GCC (C and C++ Compiler) and Development Tools

Download and Install C, C++ Compiler on Red Hat Enterprise Linux 5 (RHEL)

Mac OS X: Install GCC Compiler with Xcode

Where is My Linux GNU C or GCC Compilers Are Installed?

HowTo: Compile And Run a C/C++ Code In Linux

RHEL / CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python & Debuggers

HowTo Compiling C Program And Creating Executable File Under a Linux / UNIX / *BSD

How To Install ncurses Library on a Linux

Linux Find Out What Compilers Are Installed or Available On The System

Linux Find Out GNU gcc Compiler Version Used To Compile Running Kernel

Howto see output of C program in Linux or UNIX



Leave a Reply

Your email address will not be published. Required fields are marked *