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.
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:
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:
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:
To compile, enter:$ make a
Run it as follows:$ ./a
Sample outputs:
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:
$ man gcc
$ man make
- 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