Previous Page
Next Page

18.2. Obtaining and Installing GCC

If you have a Unix-like system, there's a fair chance that GCC is already installed. To find out, type cc --version at the command prompt. If GCC is installed and linked to the default C compiler name cc, you will see the compiler's version number and copyright information:

$ cc --version
cc (GCC) 3.3.5 (Debian 1:3.3.5-6)
Copyright (C) 2003 Free Software Foundation 
, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

In the examples in this chapter, the dollar sign ($) at the beginning of a line represents the command prompt. What follows it is a command line that you would enter at a console to invoke GCC (or whatever program is named in the command).


It's possible that GCC is installed, but not linked to the program name cc. Just in case, try calling the compiler by its proper name:

$ gcc --version

If GCC is not installed, consult your system vendor to see whether GCC is available in a binary package for your system's software installation mechanism. Otherwise, you can obtain the source code of GCC from the Free Software Foundation (see the list of mirror sites at http://gcc.gnu.org/mirrors.html) and compile it on your system. Follow the step-by-step instructions at http://gcc.gnu.org/install/. If you want to compile programs only in C, then you need only the GCC "core distribution," which leaves out the frontends for other languages, and is only half the size of the full GCC package.

If your system has no C compiler at all, then you can't compile the GCC from source. You'll need to install it as a precompiled binary. The GCC web site maintains a list of GCC binary packages compiled by third parties for a variety of systems, from AIX to Windows, at http://gcc.gnu.org/install/binaries.html.


Previous Page
Next Page