Differences between revisions 3 and 4
Revision 3 as of 2011-12-22 16:25:35
Size: 4236
Revision 4 as of 2012-01-06 06:25:44
Size: 428
Editor: 109
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Installing GCC =

This page is intended to offer guidance to avoid some common problems when installing GCC, the official installation docs are in the [[http://gcc.gnu.org/install/index.html|Installing GCC]] section of the main GCC documentation.

For most people the easiest way to install GCC is to install a package made for your operating system. The GCC project does not provide pre-built binaries of GCC, only source code, but all GNU/Linux distributions include packages for GCC. The BSD-based systems include GCC in their ports collections. For other operating systems the [[http://gcc.gnu.org/install/binaries.html|Installing GCC: Binaries]] page lists some third-party sources of GCC binaries.

If you cannot find suitable binaries for your system, or you need a newer version than is available, you will need to build GCC from source in order to install it.

Many people rush into trying to build GCC without reading the [[http://gcc.gnu.org/install/index.html|installation docs]] properly and make one or more of these common mistakes:

 * do not run `./configure`, this is not supported, you need to run configure from outside the source directory (this is a [[FAQ#configure|FAQ]])

 * if GCC links dynamically to the GMP, MPFR or MPC then the relevant shared libraries must be in the dynamic linker's path, both when building gcc ''and'' when using the installed compiler (this is also a [[FAQ#configure_suffix|FAQ]])

=== Support libraries ===

See [[http://gcc.gnu.org/install/prerequisites.html|Installing GCC: Prequisites]] for the software required to build GCC. If you do not have the GMP, MPFR and MPC support libraries already installed as part of your operating system then there are two simple ways to proceed, and one difficult, error-prone way. For some reason most people choose the difficult way. The easy ways are:

 * Use your OS package management system to install the support libraries in standard system locations. For Debian-based systems, including Ubuntu, you should install the packages `libgmp-dev`, `libmpfr-dev` and `libmpc-dev`. For RPM-based systems, including Fedora and SuSE, you should install `gmp-devel`, `mpfr-devel` and `mpc-devel` packages. If the libraries and headers are installed in standard system directories then everything will work correctly.

 * Alternatively, after extracting the GCC source archive, simply run the `./contrib/download_prerequisites` script in the GCC source directory. That will download the support libraries and build them automatically as part of GCC and everything will work correctly.

The difficult way, which is '''not recommended''', is to download the sources for GMP, MPFR and MPC, then configure and install them in non-standard locations, then configure GCC with `--with-gmp=/some/silly/path/gmp --with-mpfr=/some/silly/path/mpfr -with-mpc=/some/silly/path/mpc`, then be forced to set `LD_LIBRARY_PATH=/some/silly/path/gmp:/some/silly/path/mpfr:/some/silly/path/mpc/lib` in your environment forever. This is silly and causes major problems for anyone who doesn't understand how dynamic linkers find libraries at runtime. Do not do this. If building GCC fails when using any of the `--with-gmp` or `--with-mpfr` or `--with-mpc` options then you probably shouldn't be using them.

=== Configuration ===

See [[http://gcc.gnu.org/install/configure.html|Installing GCC: Configuration]] for the full documentation. A major benefit of running ''srcdir''`/configure` from outside the source directory (instead of running `./configure`) is that the source directory will not be modified in any way, so if your build fails or you want to re-configure and build again, you simply delete everything in the ''objdir'' and start again.

For example, configuring and building GCC 4.6.2 should be as simple as:
tar xzf gcc-4.6.2.tar.gz
cd gcc-4.6.2
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-4.6.2/configure --prefix=/opt/gcc-4.6.2

If your build fails and your configure command has lots of complicated options you should try removing options and keep it simple. Do not add lots of configure options you don't understand, they might be the reason your build fails.
[[http://www.pandorajewelryco.com/|pandora jewelry sale]] brand is inspired by Greek mythology. [[http://www.pandorajewelryco.com/|pandora bracelets sale]] in a beautiful way to capture life's memorable moments, [[http://www.pandorajewelryco.com/pandora-charms.html/|pandora charms]] to create a beautiful, exquisite jewelry, [[http://www.pandorajewelryco.com/pandora-beads.html/|pandora beads]] also represents luck and hope.

pandora jewelry sale brand is inspired by Greek mythology. pandora bracelets sale in a beautiful way to capture life's memorable moments, pandora charms to create a beautiful, exquisite jewelry, pandora beads also represents luck and hope.

None: InstallingGCC (last edited 2017-07-20 19:47:08 by JonathanWakely)